Repository navigation
Keep lowercase letters as they are in Snake, Kebab and Camel case [patch] - #111
Merged
Merged
Conversation
…tch] ToSnakeCase lowered the output of ToMacroCase, and that round trip is not an identity for every lowercase letter: final sigma came back as sigma, the micro sign as Greek mu, and long s as s. Snake case now lowercases the split words directly, sharing the split-and-join step with macro case. Camel case keeps a first letter that is already lowercase instead of lowering the uppercase Pascal step gave it. Fixes #84 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JE3qjjjTXN28xUcTq2h6vD
|
This was referenced Oct 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #84
Problem
ToSnakeCasewasToLowerInvariantFull(input.ToMacroCase()). Uppercasing a letter and then lowercasing it doesn't always give back the same letter:ςbecomesσ,µ(U+00B5) becomesμ(U+03BC), andſbecomess. As a result"λόγος"turned into"λόγοσ", and runningToSnakeCaseon text that was already snake_case changed it. Camel case had the same problem with its first letter, which went through the Pascal step's uppercase and was then lowered again.Change
ToMacroCaseandToSnakeCasenow share a privateJoinWordsWithUnderscores(input, caseMap)that trims, splits, case-maps and joins with underscores. Macro passes the uppercase mapping and snake passes the lowercase one, so snake lowercases the split words directly, and the two can't drift apart. Kebab still builds on snake.ToCamelCasekeeps the input's first letter as it is when it is already lowercase and is the letter the Pascal step uppercased. Otherwise it falls back toToLowercaseFirstCharas before.Behaviour change worth a look
The dotless
ıis a lowercase letter, so it is now kept too:"kırmızı".ToSnakeCase()gives"kırmızı"(it used to give"kirmizi"), and"ılık su".ToCamelCase()gives"ılıkSu"(it used to give"ilıkSu"). That is what the issue's acceptance criterion asks for, since all-lowercase input should come out unchanged apart from separators. Macro and Pascal output forıis unchanged, andİis still lowered toi.Tests
ToSnakeCaseAndToKebabCaseShouldKeepLowercaseLetterscovers"λόγος","already_snake_ς","µs delay","ſtraße"and"kırmızı", and also checks that snake case is idempotent.ToCamelCaseShouldKeepALowercaseFirstLettercovers"µs delay","ςx"and"ılık su".🤖 Generated with Claude Code
https://claude.ai/code/session_01JE3qjjjTXN28xUcTq2h6vD
Generated by Claude Code