aboutsummaryrefslogtreecommitdiffhomepage
path: root/helpers/url.go
diff options
context:
space:
mode:
authorCameron Moore <[email protected]>2016-04-27 09:54:44 -0500
committerCameron Moore <[email protected]>2016-04-27 10:29:46 -0500
commite4ee1b89ad21f46dab96c9099f554bef4602650b (patch)
treebc951980cba5d2738f2ea0e050d750186d3ebcda /helpers/url.go
parent16b71bbbb4c283f29e6e757dbf1fc304703704a9 (diff)
downloadhugo-e4ee1b89ad21f46dab96c9099f554bef4602650b.tar.gz
hugo-e4ee1b89ad21f46dab96c9099f554bef4602650b.zip
helpers: Use net/url for URL parsing in AbsURL
Fixes #2112
Diffstat (limited to 'helpers/url.go')
-rw-r--r--helpers/url.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/helpers/url.go b/helpers/url.go
index 9d3db8004..00bcd67c9 100644
--- a/helpers/url.go
+++ b/helpers/url.go
@@ -148,7 +148,12 @@ func MakePermalink(host, plink string) *url.URL {
// AbsURL creates a absolute URL from the relative path given and the BaseURL set in config.
func AbsURL(path string) string {
- if strings.HasPrefix(path, "http") || strings.HasPrefix(path, "//") {
+ url, err := url.Parse(path)
+ if err != nil {
+ return path
+ }
+
+ if url.IsAbs() || strings.HasPrefix(path, "//") {
return path
}