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

Recase.to_snake/1 is not consistent with previous versions (<0.4.0) #74

Open
rwngallego opened this issue Oct 4, 2019 · 3 comments · May be fixed by #167
Open

Recase.to_snake/1 is not consistent with previous versions (<0.4.0) #74

rwngallego opened this issue Oct 4, 2019 · 3 comments · May be fixed by #167

Comments

@rwngallego
Copy link

We have seen a compatibility break from versions 0.5.0+ in Recase.to_snake/1. This happens when there are multiple uppercase letters followed by lowercase ones as you can see in the example with "CurrencyISOCode":

Versions 0.5+

iex(2)> Recase.to_snake("CurrencyISOCode")
"currency_isocode"

Previos versions <= 0.4

iex(2)> Recase.to_snake("CurrencyISOCode")
"currency_iso_code"

Is that intended? For the moment we are pinning the dependency to v0.4.0

@Defcoun
Copy link

Defcoun commented Oct 29, 2020

Please, add the ability to change every uppercase letters as in the my example:

iex(2)> Recase.to_snake("CurrencyISOCode") "currency_i_s_o_code"

@wkirschbaum
Copy link

wkirschbaum commented Oct 26, 2021

Please, add the ability to change every uppercase letters as in the my example:

iex(2)> Recase.to_snake("CurrencyISOCode") "currency_i_s_o_code"

This is what I expected as well. The current handling of consecutive capitals does not make sense to me.

I would expect the latter example to convert back

iex(8)> Recase.to_snake("someRandomWord") |> Recase.to_camel()
"someRandomWord"
iex(9)> Recase.to_snake("someRANDOMWord") |> Recase.to_camel()
"someRandomword"

Which is useful when converting json objects between api's predictably.

@sobolevn
Copy link
Member

PRs with different options are welcome! 👍

@bolek bolek linked a pull request Feb 15, 2023 that will close this issue
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