Skip to content

Pitfall using Turkish locale #81

@jhnns

Description

@jhnns

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions