Make absURL properly handle baseURL with path component

This commit is contained in:
Marek Janda
2015-11-02 21:28:29 +01:00
committed by Bjørn Erik Pedersen
parent 94c3825e5b
commit 0962470850
2 changed files with 13 additions and 1 deletions

View File

@@ -151,7 +151,17 @@ func AbsURL(path string) string {
if strings.HasPrefix(path, "http") || strings.HasPrefix(path, "//") {
return path
}
return MakePermalink(viper.GetString("BaseURL"), path).String()
baseURL := viper.GetString("BaseURL")
if strings.HasPrefix(path, "/") {
p, err := url.Parse(baseURL)
if err != nil {
panic(err)
}
p.Path = ""
baseURL = p.String()
}
return MakePermalink(baseURL, path).String()
}
// RelURL creates a URL relative to the BaseURL root.