speakingurl icon indicating copy to clipboard operation
speakingurl copied to clipboard

setting Array as `custom` replaces numbers

Open deyhle opened this issue 8 years ago • 1 comments

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 avatar Nov 23 '17 14:11 deyhle

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

deyhle avatar May 23 '18 12:05 deyhle