Recase.to_snake/1 is not consistent with previous versions (<0.4.0)
rwngallego opened this issue · 3 comments
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
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"
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.
PRs with different options are welcome! 👍