diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-11-15 15:35:28 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-11-15 18:37:11 +0300 |
commit | 5df2b79dd2734e9a00ed1692328f58c385676468 (patch) | |
tree | 43c116e383b20e8dcec07cb4ab8ac92d77b171d7 /helpers/url.go | |
parent | 12742bac71c65d65dc56548b643debda94757aee (diff) |
Fix Permalink for resource, baseURL with path and canonifyURLs set
Fixes #5226
Diffstat (limited to 'helpers/url.go')
-rw-r--r-- | helpers/url.go | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/helpers/url.go b/helpers/url.go index f167fd3d2..a24f05b12 100644 --- a/helpers/url.go +++ b/helpers/url.go @@ -283,15 +283,13 @@ func AddContextRoot(baseURL, relativePath string) string { } // PrependBasePath prepends any baseURL sub-folder to the given resource -// if canonifyURLs is disabled. -// If canonifyURLs is set, we will globally prepend the absURL with any sub-folder, -// so avoid doing anything here to avoid getting double paths. -func (p *PathSpec) PrependBasePath(rel string) string { - if p.BasePath != "" { +func (p *PathSpec) PrependBasePath(rel string, isAbs bool) string { + basePath := p.GetBasePath(!isAbs) + if basePath != "" { rel = filepath.ToSlash(rel) // Need to prepend any path from the baseURL hadSlash := strings.HasSuffix(rel, "/") - rel = path.Join(p.BasePath, rel) + rel = path.Join(basePath, rel) if hadSlash { rel += "/" } |