encodeURIComponent escapes all characters except the following: - _ . ! ~ * ' ( )
But is it possible to extend the functionality encode the above special characters as well.
I know i can do something like this:
encodeURIComponent(str).replace(/\(/g, "%28").replace(/\)/g, "%29");
but I want functionality like this, without using additional functions on the encodeURIComponent
encodeURIComponent(str);
Don't say I didn't warn you; there be dragons here:
(function() {
var _fn = encodeURIComponent;
window.encodeURIComponent = function(str) {
return _fn(str).replace(/\(/g, "%28").replace(/\)/g, "%29");
};
}());