add and use Ox.decodeURI and Ox.decodeURIComponent
This commit is contained in:
parent
7576654e0d
commit
51215c1cbe
3 changed files with 20 additions and 2 deletions
|
@ -12,7 +12,7 @@ Ox.Cookies = function() {
|
||||||
if (document.cookie && document.cookie != '') {
|
if (document.cookie && document.cookie != '') {
|
||||||
document.cookie.split('; ').forEach(function(cookie) {
|
document.cookie.split('; ').forEach(function(cookie) {
|
||||||
name = cookie.split('=')[0];
|
name = cookie.split('=')[0];
|
||||||
value[name] = decodeURIComponent(cookie.substring(name.length + 1));
|
value[name] = Ox.decodeURIComponent(cookie.substring(name.length + 1));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
|
|
@ -563,7 +563,7 @@ Ox.URL = function(options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function decodeValue(value) {
|
function decodeValue(value) {
|
||||||
return decodeURIComponent(value);
|
return Ox.decodeURIComponent(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function encodeValue(value) {
|
function encodeValue(value) {
|
||||||
|
|
|
@ -24,6 +24,24 @@ Ox.clean = function(string) {
|
||||||
})).join('\n');
|
})).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
|
Ox.endsWith <f> Tests if a string ends with a given substring
|
||||||
Equivalent to `new RegExp(Ox.escapeRegExp(substring) + '$').test(string)`.
|
Equivalent to `new RegExp(Ox.escapeRegExp(substring) + '$').test(string)`.
|
||||||
|
|
Loading…
Reference in a new issue