fireship-io / next-firebase-course

Next.js + Firebase - The Full Course
next-firebase-course-git-main.fireship.vercel.app
477 stars 217 forks source link

kebabcase doesn't filter emojis from the title #17

Open Gers2017 opened 2 years ago

Gers2017 commented 2 years ago

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