speakingurl
speakingurl copied to clipboard
Using an array as custom transformations doesn't work as expected
Hi guys,
Two problems:
- it considers the array as an object and replace number with the value at the index of the array;
- it mutates the array and starts adding properties to it.
Here is a test case:
var getSlug = require('speakingurl');
const custom = ['b'];
const slug = getSlug('0', { custom });
console.log(slug); // => 'b', '0' has been replaced with the custom char at index 0
console.log(custom); // => [ 'b', b: 'b' ] the array has been mutated and now have a `b` property
There are more examples of this issue:
const slug = getSlug('top 100 waterfalls', { custom: ["."] })
console.log(slug); // => top-1..-waterfalls