Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix toSnakeCase bug when using camelCase strings #182

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dphaener
Copy link

@dphaener dphaener commented Oct 27, 2020

The regex that was previously used to convert strings to snake_case did
not account for camelCase or StartCamelCase strings, so it simply
downcased the entire string and returned that.

This adds a new regex that is used to handle camelCase and StartCamelCase
strings, as well as the strings previously present in the test cases.

This also adds a new function called splitByNonDowncaseAlphaNumeric
that will split a string based on this new regex, trim whitespace from
all strings, and then reject empty strings.

Fixes #169

Checklist

  • issue is linked
  • changes are well described
  • tests are included

Be in accordance with the latest Code of Conduct and Guideslines of Contributing.

The regex that was previously used to convert strings to snake_case did
not account for camelCase or StartCamelCase strings, so it simply
downcased the entire string and returned that.

This adds a new regex that is used to handle camelCase and StartCamelCase
strings, as well as the strings previously present in the test cases.

This also adds a new function called `splitByNonDowncaseAlphaNumeric`
that will split a string based on this new regex, trim whitespace from
all strings, and then reject empty strings.

Fixes tommmyy#169
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

toSnakeCase function is broken when converting from camelCase
1 participant