You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
WebCC/bak/js_encode_uri_component.js

17 lines
509 B
JavaScript

function fixedEncodeURIComponent(str) {
return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
return '%' + c.charCodeAt(0).toString(16);
});
}
console.log(encodeURIComponent('[!\'()*]'))
console.log(fixedEncodeURIComponent('[!\'()*]'))
const subDelims = '!$&\\()*+,;=';
console.log(encodeURIComponent(subDelims))
console.log(fixedEncodeURIComponent(subDelims))
const unreserved = 'aAzZ09-._~';
console.log(encodeURIComponent(unreserved))
console.log(fixedEncodeURIComponent(unreserved))