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

toSnakeCase function is broken when converting from camelCase #169

Open
dphaener opened this issue Dec 2, 2019 · 5 comments · May be fixed by #182
Open

toSnakeCase function is broken when converting from camelCase #169

dphaener opened this issue Dec 2, 2019 · 5 comments · May be fixed by #182

Comments

@dphaener
Copy link

dphaener commented Dec 2, 2019

Describe the bug
Using the snake case function on a camel cased string does not properly convert the string:

> R_.toSnakeCase('fooBar') //=> 'foobar'

To Reproduce
https://ramda-extension.firebaseapp.com/repl/?v=%5E0.26.1&ve=0.10.1#?R_.toSnakeCase%28%27fooBar%27%29

Expected behavior
It should properly convert the string:

> R_.toSnakeCase('fooBar') //=> 'foo_bar'

Additional context
N/A

@tommmyy
Copy link
Owner

tommmyy commented Dec 3, 2019

woking on it

@carina-akaia
Copy link
Contributor

Any updates?

dphaener pushed a commit to dphaener/ramda-extension that referenced this issue 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 updates the regexp
that is used to handle camelCase and StartCamelCase strings.

Fixes tommmyy#169
dphaener pushed a commit to dphaener/ramda-extension that referenced this issue 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 updates the regexp
that is used to handle camelCase and StartCamelCase strings.

Fixes tommmyy#169
dphaener pushed a commit to dphaener/ramda-extension that referenced this issue 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 updates the regexp
that is used to handle camelCase and StartCamelCase strings.

Fixes tommmyy#169
dphaener pushed a commit to dphaener/ramda-extension that referenced this issue 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 updates the regexp
that is used to handle camelCase and StartCamelCase strings.

Fixes tommmyy#169
dphaener pushed a commit to dphaener/ramda-extension that referenced this issue 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 updates the regexp
that is used to handle camelCase and StartCamelCase strings.

Fixes tommmyy#169
dphaener pushed a commit to dphaener/ramda-extension that referenced this issue 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 updates the regexp
that is used to handle camelCase and StartCamelCase strings.

Fixes tommmyy#169
dphaener pushed a commit to dphaener/ramda-extension that referenced this issue 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 tommmyy#169
@dphaener dphaener linked a pull request Oct 27, 2020 that will close this issue
3 tasks
@dphaener
Copy link
Author

@KarinaDrummer @tommmyy Finally got around to addressing this: #182. :) Open to discussion on the implementation and potential edge cases here. That regex was tricky to put together. ;)

@carina-akaia
Copy link
Contributor

Cool, hope I'll have a time to join the discussion

@craineum
Copy link

Any update on when this might get merged/fixed? Thanks :)

Also, another handy thing would be to have the compliment of camelizeKeys so snakeCaseKeys or snakizeKeys. Having these two things would make it easy for talking to backends that do snake case. Can open another issue if there is interest in that.

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 a pull request may close this issue.

4 participants