Skip to content

Commit 7a4af95

Browse files
committed
Fix for regresion in devel.
1 parent ce95e91 commit 7a4af95

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/jsony.nim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,12 @@ proc camelCase(s: string): string =
165165
return s
166166

167167
proc snakeCase(s: string): string =
168+
if s.len == 0:
169+
return
168170
var prevCap = false
169171
for i, c in s:
170172
if c in {'A'..'Z'}:
171-
if result.len > 0 and result[^1] != '_' and not prevCap:
173+
if result.len > 0 and result[result.len-1] != '_' and not prevCap:
172174
result.add '_'
173175
prevCap = true
174176
result.add c.toLowerAscii()

0 commit comments

Comments
 (0)