mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-27 22:09:53 +02:00
Make absURL properly handle baseURL with path component
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
94c3825e5b
commit
0962470850
@@ -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.
|
||||
|
Reference in New Issue
Block a user