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

Decamelizing a capitalized word gives odd results #21

Closed
JanStevens opened this issue Nov 25, 2019 · 3 comments · Fixed by #23
Closed

Decamelizing a capitalized word gives odd results #21

JanStevens opened this issue Nov 25, 2019 · 3 comments · Fixed by #23

Comments

@JanStevens
Copy link

Hello,

When decamelizing an upcase word one gets odd results like this:

decamelize('ADDRESS1') === 'addres_s1'

Not sure what the logic is in it but I would expect that it returns address1

Regards

@sindresorhus
Copy link
Owner

Yes, that's a bug.

@coreyfarrell
Copy link
Contributor

This is due to the handling of acronyms, $2 of the second regular express is S1. This specific example could be fixed without breaking any existing tests by removing the \d match from the second regular expression.

I just submitted a patch to drop xregexp, if you'd like I can submit a follow-up to remove the \d from the pattern. Probably makes sense to do it as part of the semver-major just in case it is breaking to anyone?

@sindresorhus
Copy link
Owner

if you'd like I can submit a follow-up to remove the \d from the pattern. Probably makes sense to do it as part of the semver-major just in case it is breaking to anyone?

👍 That would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants