Add exceptions to ```SplitCapitalize``` function like YouTube, GitHub, etc.

pull/48/head
Henrique Dias 2015-12-13 10:30:56 +00:00
parent 63a50bfae5
commit 403d01f946
1 changed files with 12 additions and 0 deletions

View File

@ -188,9 +188,21 @@ func Run(c *config.Config) {
} }
} }
var splitCapitalizeExceptions = map[string]string{
"youtube": "YouTube",
"github": "GitHub",
"facebook": "Facebook",
"googleplus": "Google Plus",
"linkedin": "LinkedIn",
}
// SplitCapitalize splits a string by its uppercase letters and capitalize the // SplitCapitalize splits a string by its uppercase letters and capitalize the
// first letter of the string // first letter of the string
func SplitCapitalize(name string) string { func SplitCapitalize(name string) string {
if val, ok := splitCapitalizeExceptions[strings.ToLower(name)]; ok {
return val
}
var words []string var words []string
l := 0 l := 0
for s := name; s != ""; s = s[l:] { for s := name; s != ""; s = s[l:] {