Youtube videos api snippet title contains special characters in next.js

I want to get the right video snippet title that doesn’t including special characters.
I am using https://www.googleapis.com/youtube/v3/search this api with the part snippet.

Currently, I am getting the below result.
Current snippet title:

I'M GONNA CARRY HER!!! Fortnite With Karina!

Expected title:

I’m gonna carry her!!! Fortnite With Karina!

2 thoughts on “Youtube videos api snippet title contains special characters in next.js”

  1. I’m using escape-goat as it operates as either a standalone function or as a tagged template literal, depending on your use case:

    const {htmlUnescape} = require('escape-goat');
    
    htmlUnescape("I'M GONNA CARRY HER!!! Fortnite With Karina!");
    //=> 'I'm gonna carry her!!! Fortnite With Karina!'
    
    htmlUnescape`Title: ${"I'M GONNA CARRY HER!!! Fortnite With Karina!"}`;
    //=> 'Title: I'm gonna carry her!!! Fortnite With Karina!'
    

    When dealing with html encode/decode, always be wary of potential XSS exploitation.

    Reply

Leave a Comment