uslug icon indicating copy to clipboard operation
uslug copied to clipboard

Trailing `-` is Not Desired

Open ilyaigpetrov opened this issue 7 years ago • 1 comments

https://runkit.com/embed/d6c7frrx3zob

const uslug = require("uslug");
uslug("Boom ❤️");

Expected: boom Actual: boom-️

ilyaigpetrov avatar Jun 09 '18 17:06 ilyaigpetrov

It happens because of \ufe0f which:

This codepoint may change the appearance of the preceding character. If that is a symbol, dingbat or emoji, U+FE0F forces it to be rendered as a colorful image as compared to a monochrome text variant.

The source To fix this I use:

const slugify = (text) =>
  uslug(text).replace(/[-\ufe0f]+$/ug, '');

ilyaigpetrov avatar Jun 12 '18 09:06 ilyaigpetrov