1
0
Fork 0
forked from 0x2620/oxjs

add and use Ox.decodeURI and Ox.decodeURIComponent

This commit is contained in:
rlx 2013-08-14 18:53:13 +00:00
commit 51215c1cbe
3 changed files with 20 additions and 2 deletions

View file

@ -24,6 +24,24 @@ Ox.clean = function(string) {
})).join('\n');
};
/*@
Ox.decodeURIComponent <f> Decodes URI
Unlike window.decodeURI, this doesn't throw on trailing '%'.
(string) -> <s> Decoded string
@*/
Ox.decodeURI = function(string) {
return decodeURIComponent(string.replace(/%(?![0-7][0-9A-F])/g, '%25'));
};
/*@
Ox.decodeURIComponent <f> Decodes URI component
Unlike window.decodeURIComponent, this doesn't throw on trailing '%'.
(string) -> <s> Decoded string
@*/
Ox.decodeURIComponent = function(string) {
return decodeURIComponent(string.replace(/%(?![0-7][0-9A-F])/g, '%25'));
};
/*@
Ox.endsWith <f> Tests if a string ends with a given substring
Equivalent to `new RegExp(Ox.escapeRegExp(substring) + '$').test(string)`.