Skip to content

Commit

Permalink
Refactor toFirstLetterLower
Browse files Browse the repository at this point in the history
This is getting hairy so a map makes sense.
  • Loading branch information
inancgumus committed Feb 21, 2023
1 parent 53125ea commit 0ae492d
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions browser/mapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,19 @@ func toFirstLetterLower(s string) string {
// Special cases.
// Instead of loading up an acronyms list, just do this.
// Good enough for our purposes.
switch s {
default:
return strings.ToLower(s[:1]) + s[1:]
case "URL":
return "url"
case "JSON":
return "json"
case "JSONValue":
return "jsonValue"
special := map[string]string{
"JSON": "json",
"JSONValue": "jsonValue",
"URL": "url",
}
if v, ok := special[s]; ok {
return v
}
if s == "" {
return ""
}

return strings.ToLower(s[:1]) + s[1:]
}

// isCustomMapping returns true if the method is a custom mapping
Expand Down

0 comments on commit 0ae492d

Please sign in to comment.