How to encode IRI (Internationalized Resource Identifier) to actual text in NextJS?

48 views Asked by At

actual URL - http://localhost:3000/यह-दुकान-है

this URL is converted to IRI - http://localhost:3000/%E0%A4%AF%E0%A4%B9-%E0%A4%A6%E0%A5%81%E0%A4%95%E0%A4%BE%E0%A4%A8-%E0%A4%B9%E0%A5%88

Is there any possibility to convert it back to real URL from IRI in NextJs ?

1

There are 1 answers

0
Rajendra A Verma On BEST ANSWER

We can get IRI to actual text from decodeURI() in nextJS.

for example :

const convertedUrl = decodeURI("http://localhost:3000/%E0%A4%AF%E0%A4%B9-%E0%A4%A6%E0%A5%81%E0%A4%95%E0%A4%BE%E0%A4%A8-%E0%A4%B9%E0%A5%88")
console.log(convertedUrl)