Trong Javascript bạn có thể dịch ngược chuỗi từ đoạn URI trên website bằng hàm decodeURI().
Ví dụ:
const uri = "https://www.mozilla.org/en-US/?x=xin chao moi nguoi"; const encoded = encodeURI(uri); console.log(encoded); // expected output: "https://www.mozilla.org/en-US/?x=xin%20chao%20moi%20nguoi" try { console.log(decodeURI(encoded)); // expected output: "https://www.mozilla.org/en-US/?x=xin chao moi nguoi" } catch (e) { // catches a malformed URI console.error(e); }
In