next-firebase-course icon indicating copy to clipboard operation
next-firebase-course copied to clipboard

kebabcase doesn't filter emojis from the title

Open Gers2017 opened this issue 3 years ago β€’ 0 comments

I was trying to imitate dev.to's posts full of emojis and I found this bug

The function does not filter Unicode emojis, which makes next.js unable to pre-render posts correctly due to the post slug

image

image

after some googling I found a simple solution to this

  let str = "Hi! 😺😺😺😺 Hello tomπŸ‘©β€πŸš’πŸ‘¨β€πŸ’»";
  let regex = new RegExp(/\p{Emoji}/gu);
  console.log(str.replace(regex, ""));

another solution might be the one supplied here Mozilla docs

Gers2017 avatar Feb 24 '22 23:02 Gers2017