From 1f6e9779237a07d172c82fc407ec2e38ef5f8a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Schl=C3=BCter?= Date: Sun, 4 Nov 2018 14:34:51 +0100 Subject: [PATCH] Fix acronyms followed by uppercase letters, e.g. `JWTName` (#8) --- ident.go | 6 ++++++ ident_test.go | 3 +++ 2 files changed, 9 insertions(+) diff --git a/ident.go b/ident.go index f70f175..9127674 100644 --- a/ident.go +++ b/ident.go @@ -72,6 +72,12 @@ func toParts(s string) []string { prev = c continue } + if unicode.IsUpper(c) && baseAcronyms[strings.ToUpper(x)] { + parts = xappend(parts, x) + x = cs + prev = c + continue + } if unicode.IsLetter(c) || unicode.IsDigit(c) || unicode.IsPunct(c) || c == '`' { prev = c x += cs diff --git a/ident_test.go b/ident_test.go index f648248..034acb0 100644 --- a/ident_test.go +++ b/ident_test.go @@ -17,6 +17,9 @@ func Test_New(t *testing.T) { {"widget/ID", []string{"widget", "ID"}}, {"widgetID", []string{"widget", "ID"}}, {"widgetName", []string{"widget", "Name"}}, + {"JWTName", []string{"JWT", "Name"}}, + {"JWTname", []string{"JWTname"}}, + {"jwtname", []string{"jwtname"}}, {"sql", []string{"SQL"}}, {"sQl", []string{"SQL"}}, {"id", []string{"ID"}},