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

Using an array as custom transformations doesn't work as expected #124

Open
atomrc opened this issue Oct 2, 2018 · 1 comment · May be fixed by #136
Open

Using an array as custom transformations doesn't work as expected #124

atomrc opened this issue Oct 2, 2018 · 1 comment · May be fixed by #136

Comments

@atomrc
Copy link

atomrc commented Oct 2, 2018

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
@david-benes
Copy link

david-benes commented Feb 11, 2021

There are more examples of this issue:


const slug = getSlug('top 100 waterfalls', { custom: ["."] })
console.log(slug); // => top-1..-waterfalls

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 a pull request may close this issue.

2 participants