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

setting Array as custom replaces numbers #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

deyhle
Copy link

@deyhle deyhle commented Nov 23, 2017

I found a bug when using the option to set an Array of allowed characters by giving an Array to the custom option: it replaces numbers in the string with the allowed characters.

Example:

getSlug('0.1,', { custom: ['.', ','] })
// expected: '0.1,' (no replacement)
// actual: '0011' (. is replaced with 0, , is replaced with 1)

The reason is that the check if the custom property is an object also returns true if it is an Array. Because of that a replacement map is set for the Array indizes and 0, 1, … are replaced with the custom allowed characters.

This pull requests adds a test and a fix for that by additionally checking if the object is not an Array.
It would be great if you could publish an update to npm with that fix

@deyhle
Copy link
Author

deyhle commented May 23, 2018

Could you please merge this pull request and publish to npm?

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

Successfully merging this pull request may close these issues.

1 participant