helpers: Use net/url for URL parsing in AbsURL

Fixes #2112
This commit is contained in:
Cameron Moore
2016-04-27 09:54:44 -05:00
parent 16b71bbbb4
commit e4ee1b89ad
2 changed files with 8 additions and 1 deletions

View File

@@ -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
}