Fix incorrect delimiter between dot and cap

This commit is contained in:
Nathan Baulch 2020-08-16 22:35:25 +10:00
parent 486369db5a
commit a6b8dcde35
2 changed files with 3 additions and 3 deletions

View File

@ -78,8 +78,8 @@ func ToScreamingDelimited(s string, delimiter uint8, ignore uint8, screaming boo
// add underscore if next letter case type is changed
if (vIsCap && nextIsLow) || (vIsLow && nextIsCap) {
if prevIgnore := ignore > 0 && i > 0 && s[i-1] == ignore; !prevIgnore {
if i > 0 && vIsCap && nextIsLow {
if prevDelim := len(n) > 0 && n[len(n)-1] == delimiter; !prevDelim {
if vIsCap && nextIsLow {
if prevIsCap := i > 0 && s[i-1] >= 'A' && s[i-1] <= 'Z'; prevIsCap {
n += string(delimiter)
}
}

View File

@ -84,7 +84,7 @@ func toSnakeWithIgnore(tb testing.TB) {
{"JSONData", "json_data"},
{"AwesomeActivity.UserID", "awesome_activity.user_id", "."},
{"AwesomeActivity.User.Id", "awesome_activity.user.id", "."},
{"AwesomeUsername@Awesome.Com", "awesome_username@awesome._com", "@"},
{"AwesomeUsername@Awesome.Com", "awesome_username@awesome.com", "@"},
}
for _, i := range cases {
in := i[0]