can-deparam
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -39,2 +39,8 @@ var deparam = require('./can-deparam'); | ||
}); | ||
test('Invalid encoding', function() { | ||
var data = deparam('foo=%0g'); | ||
deepEqual(data, { | ||
foo: '%0g' | ||
}); | ||
}); | ||
/** / | ||
@@ -41,0 +47,0 @@ test("deparam an array", function(){ |
@@ -24,4 +24,14 @@ var namespace = require("can-namespace"); | ||
paramTest = /([^?#]*)(#.*)?$/, | ||
entityRegex = /%([^0-9a-f][0-9a-f]|[0-9a-f][^0-9a-f]|[^0-9a-f][^0-9a-f])/i, | ||
prep = function (str) { | ||
return decodeURIComponent(str.replace(/\+/g, ' ')); | ||
str = str.replace(/\+/g, ' '); | ||
try { | ||
return decodeURIComponent(str); | ||
} | ||
catch (e) { | ||
return decodeURIComponent(str.replace(entityRegex, function(match, hex) { | ||
return '%25' + hex; | ||
})); | ||
} | ||
}; | ||
@@ -28,0 +38,0 @@ module.exports = namespace.deparam = function (params) { |
@@ -1,6 +0,13 @@ | ||
/*can-deparam@0.0.0#can-deparam*/ | ||
/*can-deparam@1.0.0#can-deparam*/ | ||
define(function (require, exports, module) { | ||
var namespace = require('can-namespace'); | ||
var digitTest = /^\d+$/, keyBreaker = /([^\[\]]+)|(\[\])/g, paramTest = /([^?#]*)(#.*)?$/, prep = function (str) { | ||
return decodeURIComponent(str.replace(/\+/g, ' ')); | ||
var digitTest = /^\d+$/, keyBreaker = /([^\[\]]+)|(\[\])/g, paramTest = /([^?#]*)(#.*)?$/, entityRegex = /%([^0-9a-f][0-9a-f]|[0-9a-f][^0-9a-f]|[^0-9a-f][^0-9a-f])/i, prep = function (str) { | ||
str = str.replace(/\+/g, ' '); | ||
try { | ||
return decodeURIComponent(str); | ||
} catch (e) { | ||
return decodeURIComponent(str.replace(entityRegex, function (match, hex) { | ||
return '%25' + hex; | ||
})); | ||
} | ||
}; | ||
@@ -7,0 +14,0 @@ module.exports = namespace.deparam = function (params) { |
@@ -1,5 +0,12 @@ | ||
/*can-deparam@0.0.0#can-deparam*/ | ||
/*can-deparam@1.0.0#can-deparam*/ | ||
var namespace = require('can-namespace'); | ||
var digitTest = /^\d+$/, keyBreaker = /([^\[\]]+)|(\[\])/g, paramTest = /([^?#]*)(#.*)?$/, prep = function (str) { | ||
return decodeURIComponent(str.replace(/\+/g, ' ')); | ||
var digitTest = /^\d+$/, keyBreaker = /([^\[\]]+)|(\[\])/g, paramTest = /([^?#]*)(#.*)?$/, entityRegex = /%([^0-9a-f][0-9a-f]|[0-9a-f][^0-9a-f]|[^0-9a-f][^0-9a-f])/i, prep = function (str) { | ||
str = str.replace(/\+/g, ' '); | ||
try { | ||
return decodeURIComponent(str); | ||
} catch (e) { | ||
return decodeURIComponent(str.replace(entityRegex, function (match, hex) { | ||
return '%25' + hex; | ||
})); | ||
} | ||
}; | ||
@@ -6,0 +13,0 @@ module.exports = namespace.deparam = function (params) { |
@@ -110,7 +110,14 @@ /*[global-shim-start]*/ | ||
) | ||
/*can-deparam@0.0.0#can-deparam*/ | ||
/*can-deparam@1.0.0#can-deparam*/ | ||
define('can-deparam', function (require, exports, module) { | ||
var namespace = require('can-namespace'); | ||
var digitTest = /^\d+$/, keyBreaker = /([^\[\]]+)|(\[\])/g, paramTest = /([^?#]*)(#.*)?$/, prep = function (str) { | ||
return decodeURIComponent(str.replace(/\+/g, ' ')); | ||
var digitTest = /^\d+$/, keyBreaker = /([^\[\]]+)|(\[\])/g, paramTest = /([^?#]*)(#.*)?$/, entityRegex = /%([^0-9a-f][0-9a-f]|[0-9a-f][^0-9a-f]|[^0-9a-f][^0-9a-f])/i, prep = function (str) { | ||
str = str.replace(/\+/g, ' '); | ||
try { | ||
return decodeURIComponent(str); | ||
} catch (e) { | ||
return decodeURIComponent(str.replace(entityRegex, function (match, hex) { | ||
return '%25' + hex; | ||
})); | ||
} | ||
}; | ||
@@ -117,0 +124,0 @@ module.exports = namespace.deparam = function (params) { |
{ | ||
"name": "can-deparam", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Deserialize a query string into an array or object.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://canjs.com/", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19655
363
2