johnnyji / proper_case

Converts keys of maps to `snake_case`, useful as a plug to format params in the Phoenix connection pipeline
MIT License
89 stars 26 forks source link

Fix snake case with space in key string #25

Closed vitorleal closed 4 years ago

vitorleal commented 5 years ago

Remove spaces on word before convert to snake case to prevent string result like

ProperCase.to_snake_case(%{"Multi Word Keys" => "some value"})
%{"multi _word _keys" => "some value"}

Fix https://github.com/johnnyji/proper_case/issues/13

jeremyjh commented 4 years ago

As I mentioned in the issue, I don't think there should be an insertion of underscores at all for a string that is not in camelCase or PascalCase, since the purpose of the function is to translate those two cases. If the string has spaces it should be left alone entirely IMO.