summaryrefslogtreecommitdiffstats
path: root/helpers/url.go
diff options
context:
space:
mode:
authorMarek Janda <nyx@nyx.cz>2015-11-02 21:28:29 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-03-10 11:08:50 +0100
commit0962470850ed6802b645d5bd6663db60807c8f5b (patch)
treeb5d070c8f29404956e46b00c46440e8a8b0542e6 /helpers/url.go
parent94c3825e5bdda9c57b1e8782caa3c407cfad711e (diff)
Make absURL properly handle baseURL with path component
Diffstat (limited to 'helpers/url.go')
-rw-r--r--helpers/url.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/helpers/url.go b/helpers/url.go
index bebcb8663..749b2eeac 100644
--- a/helpers/url.go
+++ b/helpers/url.go
@@ -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.