Extract the project slug more betterly
This commit is contained in:
parent
bde7c576e3
commit
b9645a6315
|
@ -56,6 +56,10 @@ func SetS3BaseUrl(base string) {
|
||||||
S3BaseUrl = base
|
S3BaseUrl = base
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetBaseHost() string {
|
||||||
|
return baseUrlParsed.Host
|
||||||
|
}
|
||||||
|
|
||||||
func Url(path string, query []Q) string {
|
func Url(path string, query []Q) string {
|
||||||
return ProjectUrl(path, query, "")
|
return ProjectUrl(path, query, "")
|
||||||
}
|
}
|
||||||
|
|
|
@ -361,11 +361,8 @@ func LoadCommonWebsiteData(c *RequestContext) (bool, ResponseData) {
|
||||||
|
|
||||||
// get project
|
// get project
|
||||||
{
|
{
|
||||||
slug := ""
|
hostPrefix := strings.TrimSuffix(c.Req.Host, hmnurl.GetBaseHost())
|
||||||
hostParts := strings.SplitN(c.Req.Host, ".", 3)
|
slug := strings.TrimRight(hostPrefix, ".")
|
||||||
if len(hostParts) >= 3 {
|
|
||||||
slug = hostParts[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
dbProject, err := FetchProjectBySlug(c.Context(), c.Conn, slug)
|
dbProject, err := FetchProjectBySlug(c.Context(), c.Conn, slug)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue