diff options
author | Anthony Fok <foka@debian.org> | 2015-03-11 11:34:57 -0600 |
---|---|---|
committer | bep <bjorn.erik.pedersen@gmail.com> | 2015-03-11 21:55:00 +0100 |
commit | 67df33f50069445d53d373790e8c636e47013a72 (patch) | |
tree | c4e9d646f32aa2a7a40e6c5597b904647bc85e3f /helpers/url.go | |
parent | 00f07c5374d859057c6e7c4731000b5978364819 (diff) |
Correct initialisms as suggested by golint
First step to use initialisms that golint suggests,
for example:
Line 116: func GetHtmlRenderer should be GetHTMLRenderer
as see on http://goreportcard.com/report/spf13/hugo
Thanks to @bep for the idea!
Note that command-line flags (cobra and pflag)
as well as struct fields like .BaseUrl and .Url
that are used in Go HTML templates need more work
to maintain backward-compatibility, and thus
are NOT yet dealt with in this commit.
First step in fixing #959.
Diffstat (limited to 'helpers/url.go')
-rw-r--r-- | helpers/url.go | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/helpers/url.go b/helpers/url.go index b3b9779c3..b9b58d050 100644 --- a/helpers/url.go +++ b/helpers/url.go @@ -52,7 +52,7 @@ func (PathBridge) Separator() string { var pathBridge PathBridge -func sanitizeUrlWithFlags(in string, f purell.NormalizationFlags) string { +func sanitizeURLWithFlags(in string, f purell.NormalizationFlags) string { s, err := purell.NormalizeURLString(in, f) if err != nil { return in @@ -88,20 +88,20 @@ func sanitizeUrlWithFlags(in string, f purell.NormalizationFlags) string { } // SanitizeUrl sanitizes the input URL string. -func SanitizeUrl(in string) string { - return sanitizeUrlWithFlags(in, purell.FlagsSafe|purell.FlagRemoveTrailingSlash|purell.FlagRemoveDotSegments|purell.FlagRemoveDuplicateSlashes|purell.FlagRemoveUnnecessaryHostDots|purell.FlagRemoveEmptyPortSeparator) +func SanitizeURL(in string) string { + return sanitizeURLWithFlags(in, purell.FlagsSafe|purell.FlagRemoveTrailingSlash|purell.FlagRemoveDotSegments|purell.FlagRemoveDuplicateSlashes|purell.FlagRemoveUnnecessaryHostDots|purell.FlagRemoveEmptyPortSeparator) } // SanitizeUrlKeepTrailingSlash is the same as SanitizeUrl, but will keep any trailing slash. -func SanitizeUrlKeepTrailingSlash(in string) string { - return sanitizeUrlWithFlags(in, purell.FlagsSafe|purell.FlagRemoveDotSegments|purell.FlagRemoveDuplicateSlashes|purell.FlagRemoveUnnecessaryHostDots|purell.FlagRemoveEmptyPortSeparator) +func SanitizeURLKeepTrailingSlash(in string) string { + return sanitizeURLWithFlags(in, purell.FlagsSafe|purell.FlagRemoveDotSegments|purell.FlagRemoveDuplicateSlashes|purell.FlagRemoveUnnecessaryHostDots|purell.FlagRemoveEmptyPortSeparator) } // Similar to MakePath, but with Unicode handling // Example: // uri: Vim (text editor) // urlize: vim-text-editor -func Urlize(uri string) string { +func URLize(uri string) string { sanitized := MakePathToLower(uri) // escape unicode letters @@ -148,9 +148,9 @@ func MakePermalink(host, plink string) *url.URL { // AddContextRoot adds the context root to an URL if it's not already set. // For relative URL entries on sites with a base url with a context root set (i.e. http://example.com/mysite), // relative URLs must not include the context root if canonifyUrls is enabled. But if it's disabled, it must be set. -func AddContextRoot(baseUrl, relativePath string) string { +func AddContextRoot(baseURL, relativePath string) string { - url, err := url.Parse(baseUrl) + url, err := url.Parse(baseURL) if err != nil { panic(err) } @@ -164,16 +164,16 @@ func AddContextRoot(baseUrl, relativePath string) string { return newPath } -func UrlizeAndPrep(in string) string { - return UrlPrep(viper.GetBool("UglyUrls"), Urlize(in)) +func URLizeAndPrep(in string) string { + return URLPrep(viper.GetBool("UglyURLs"), URLize(in)) } -func UrlPrep(ugly bool, in string) string { +func URLPrep(ugly bool, in string) string { if ugly { - x := Uglify(SanitizeUrl(in)) + x := Uglify(SanitizeURL(in)) return x } - x := PrettifyUrl(SanitizeUrl(in)) + x := PrettifyURL(SanitizeURL(in)) if path.Ext(x) == ".xml" { return x } @@ -186,8 +186,8 @@ func UrlPrep(ugly bool, in string) string { } // PrettifyUrl takes a URL string and returns a semantic, clean URL. -func PrettifyUrl(in string) string { - x := PrettifyUrlPath(in) +func PrettifyURL(in string) string { + x := PrettifyURLPath(in) if path.Base(x) == "index.html" { return path.Dir(x) @@ -205,7 +205,7 @@ func PrettifyUrl(in string) string { // /section/name.html becomes /section/name/index.html // /section/name/ becomes /section/name/index.html // /section/name/index.html becomes /section/name/index.html -func PrettifyUrlPath(in string) string { +func PrettifyURLPath(in string) string { return PrettiyPath(in, pathBridge) } |