diff options
Diffstat (limited to 'helpers')
-rw-r--r-- | helpers/url.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/helpers/url.go b/helpers/url.go index 927e3c87c..085f9e9fa 100644 --- a/helpers/url.go +++ b/helpers/url.go @@ -169,6 +169,17 @@ func AbsURL(path string) string { return MakePermalink(baseURL, path).String() } +// IsAbsURL determines whether the given path points to an absolute URL. +// TODO(bep) ml tests +func IsAbsURL(path string) bool { + url, err := url.Parse(path) + if err != nil { + return false + } + + return url.IsAbs() || strings.HasPrefix(path, "//") +} + // RelURL creates a URL relative to the BaseURL root. // Note: The result URL will not include the context root if canonifyURLs is enabled. func RelURL(path string) string { |