Hi 👋
thanks for this module – and all the other modules 🙏
I recently ran into a problem where my JSON objects were transformed into this:
"customersİd": 619336, // <-- notice the different capital i character
"projectsİd": 631365,
"usersİd": 62488,
Unfortunately, this didn't happen locally and during testing, it only happened in production in case the user was using the Turkish locale. There's already an issue in the camelcase repo describing the problem.
I kind of understand that toLocaleUpperCase() is the default for the camelcase package since the context of the "to camelcase" transformation is not clear.
However, I think that camelcase-keys should use the locale-independent toUpperCase(). This is because I'm assuming that most people are using this module in a context where they want to transform API responses to camelCase in a predictable way. Using toLocaleUpperCase() poses the risk that API responses are transformed into a different shape on runtime. Also toLocaleUpperCase("en") doesn't really help since the locale might be unavailable and the host might fall back to the default locale.
I think this issue could be solved like this:
- Add an option to
camelcase to use the locale-independent toUpperCase()
- Use that option as default in
camelcase-keys
What do you think? 😀 I'd be willing to help out if that's ok.
Hi 👋
thanks for this module – and all the other modules 🙏
I recently ran into a problem where my JSON objects were transformed into this:
Unfortunately, this didn't happen locally and during testing, it only happened in production in case the user was using the Turkish locale. There's already an issue in the camelcase repo describing the problem.
I kind of understand that
toLocaleUpperCase()is the default for the camelcase package since the context of the "to camelcase" transformation is not clear.However, I think that
camelcase-keysshould use the locale-independenttoUpperCase(). This is because I'm assuming that most people are using this module in a context where they want to transform API responses to camelCase in a predictable way. UsingtoLocaleUpperCase()poses the risk that API responses are transformed into a different shape on runtime. AlsotoLocaleUpperCase("en")doesn't really help since the locale might be unavailable and the host might fall back to the default locale.I think this issue could be solved like this:
camelcaseto use the locale-independenttoUpperCase()camelcase-keysWhat do you think? 😀 I'd be willing to help out if that's ok.