Skip to content

Commit 5fc090e

Browse files
committed
Merge pull request #15 from hajimehoshi/keep-uppercases
Keep upper-case characters (#14)
2 parents fafa0b3 + 362df64 commit 5fc090e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

json-to-go.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,19 @@ function jsonToGo(json, typename)
167167
"SMTP", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "UID", "UUID", "URI",
168168
"URL", "UTF8", "VM", "XML", "XSRF", "XSS"
169169
];
170-
171-
return str.replace(/(^|[^a-z])([a-z]+)/ig, function(unused, sep, frag)
170+
171+
return str.replace(/(^|[^a-zA-Z])([a-z]+)/g, function(unused, sep, frag)
172172
{
173173
if (commonInitialisms.indexOf(frag.toUpperCase()) >= 0)
174174
return sep + frag.toUpperCase();
175175
else
176176
return sep + frag[0].toUpperCase() + frag.substr(1).toLowerCase();
177+
}).replace(/([A-Z])([a-z]+)/g, function(unused, sep, frag)
178+
{
179+
if (commonInitialisms.indexOf(sep + frag.toUpperCase()) >= 0)
180+
return (sep + frag).toUpperCase();
181+
else
182+
return sep + frag;
177183
});
178184
}
179185
}

0 commit comments

Comments
 (0)