Skip to content

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

@atomrc

Description

@atomrc

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions