Baseline Widely available
ÐеÑод decodeURIComponent()
декодиÑÑÐµÑ ÑпÑавлÑÑÑие поÑледоваÑелÑноÑÑи Ñимволов в компоненÑе Uniform Resource Identifier (URI), ÑозданнÑе Ñ Ð¿Ð¾Ð¼Ð¾ÑÑÑ Ð¼ÐµÑода encodeURIComponent
или дÑÑгой подобной пÑоÑедÑÑÑ.
function containsEncodedComponents(x) {
// ie ?,=,&,/ etc
return decodeURI(x) !== decodeURIComponent(x);
}
console.log(containsEncodedComponents("%3Fx%3Dtest")); // ?x=test
// Expected output: true
console.log(containsEncodedComponents("%D1%88%D0%B5%D0%BB%D0%BB%D1%8B")); // ÑеллÑ
// Expected output: false
СинÑакÑиÑ
decodeURIComponent(encodedURI)ÐаÑамеÑÑÑ
encodedURI
СÑÑока, ÑодеÑжаÑÐ°Ñ Ð·Ð°ÐºÐ¾Ð´Ð¸ÑованнÑй ÐºÐ¾Ð¼Ð¿Ð¾Ð½ÐµÐ½Ñ Uniform Resource Identifier.
ÐÐ¾Ð²Ð°Ñ ÑÑÑока, пÑедÑÑавлÑÑÑÐ°Ñ Ñобой декодиÑованнÑÑ Ð²ÐµÑÑÐ¸Ñ ÐºÐ¾Ð¼Ð¿Ð¾Ð½ÐµÐ½Ñа Uniform Resource Identifier (URI), пеÑеданного в каÑеÑÑве паÑамеÑÑа.
ÐÑклÑÑениÑÐÑи непÑавилÑном иÑполÑзовании вÑдаÑÑ Ð¸ÑклÑÑение URIError
("невеÑнÑй ÑоÑÐ¼Ð°Ñ Ð¿Ð¾ÑледоваÑелÑноÑÑи URI").
ÐаменÑÐµÑ ÐºÐ°Ð¶Ð´ÑÑ ÑпÑавлÑÑÑÑÑ Ð¿Ð¾ÑледоваÑелÑноÑÑÑ Ð² закодиÑованном компоненÑе URI ÑооÑвеÑÑÑвÑÑÑим ей Ñимволом.
ÐÑимеÑÑ ÐекодиÑование компоненÑа киÑиллиÑеÑкого URLdecodeURIComponent("JavaScript_%D1%88%D0%B5%D0%BB%D0%BB%D1%8B");
// "JavaScript_ÑеллÑ"
ÐеÑеÑ
Ð²Ð°Ñ Ð¾Ñибок
try {
var a = decodeURIComponent("%E0%A4%A");
} catch (e) {
console.error(e);
}
// URIError: malformed URI sequence
СпеÑиÑикаÑии СовмеÑÑимоÑÑÑ Ñ Ð±ÑаÑзеÑами СмоÑÑиÑе Ñакже
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4