stringutil: Handle properly acronyms in the CamelToSnakeCase#79
stringutil: Handle properly acronyms in the CamelToSnakeCase#79AlexisMontagne merged 1 commit intomasterfrom
Conversation
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| } | ||
|
|
||
| return strings.ToLower(s) | ||
| return strings.ToLower(strings.TrimPrefix(s, "_")) |
There was a problem hiding this comment.
Bug: Regex Overlap Causes Double Underscore
The implementation introduces double underscores when an acronym is followed by a capitalized word. When the second regex ([A-Z]+) matches a sequence of uppercase letters that already has an underscore prefix from the first pass, it adds another underscore. For example, "WithAcronymLikeURL" becomes "with_acronym_like__url" instead of the expected "with_acronym_like_url" due to the double underscore before "url". The test case will fail because the actual output doesn't match the expected output.
| } | ||
|
|
||
| return strings.ToLower(s) | ||
| return strings.ToLower(strings.TrimPrefix(s, "_")) |
What does this PR do?
Fixes #
What are the observable changes?
Good PR checklist
Additional Notes