simov / slugify

Slugifies a string
MIT License
1.47k stars 126 forks source link

Inconsistent behaviour with emojis when remove option's regex is provided #184

Closed rdxpr closed 8 months ago

rdxpr commented 8 months ago

I have noticed that when using the slugify function without any extra options it outputs a slug without emojis , but when a removal regex is provided the output contains emojis .

import slugify from "slugify";
const title = "This is a title 📌 : with a symbol";
const slugifiedTitleWithEmoji = slugify(title, {
  remove: /[*+~.()'"!:@]/g,
  lower: true,
});
console.log(slugifiedTitleWithEmoji); //this-is-a-title-📌-with-a-symbol
const slugifiedTitleWithoutEmoji = slugify(title , { lower:true });
console.log(slugifiedTitleWithoutEmoji); //this-is-a-title-:-with-a-symbol

i would expect that when i use the remove regex the output should still not contain emojis , anyways this is a just a minor inconvenience feel free to close this issue if it does not make sense to change the current behaviour

Trott commented 8 months ago

i would expect that when i use the remove regex the output should still not contain emojis , anyways this is a just a minor inconvenience feel free to close this issue if it does not make sense to change the current behaviour

FWIW, the slug module behaves as you expect, returning this-is-a-title-with-a-symbol in both cases.

rdxpr commented 8 months ago

FWIW, the slug module behaves as you expect, returning this-is-a-title-with-a-symbol in both cases.

thanks i will try it , i closed the issue as using strict mode with slugify gave me the desired output as well