form-urlencoded
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -5,2 +5,3 @@ // Filename: formurlencoded.js | ||
// | ||
// 5.1, http://www.w3.org/TR/html5/forms.html#url-encoded-form-data | ||
// input: {one:1,two:2} return: '[one]=1&[two]=2' | ||
@@ -12,2 +13,8 @@ | ||
optsorted = opts.sorted || false; | ||
function getKeys(obj) { | ||
var keys = Object.keys(obj); | ||
return optsorted ? keys.sort() : keys; | ||
} | ||
@@ -20,8 +27,2 @@ function getNestValsArrAsStr(arr) { | ||
function getKeys(obj) { | ||
var keys = Object.keys(obj); | ||
return optsorted ? keys.sort() : keys; | ||
} | ||
function getObjNestVals (name, obj) { | ||
@@ -53,4 +54,4 @@ var objKeyStr = ':name[:prop]'; | ||
if (Array.isArray(value)) { | ||
f = getArrNestVals(name, value); | ||
if (value === null) { | ||
f = optignorenull ? f : encode(name) + '=' + f; | ||
} else if (type === 'string') { | ||
@@ -62,8 +63,6 @@ f = encode(name) + '=' + formEncodeString(value); | ||
f = encode(name) + '=' + value; | ||
} else if (Array.isArray(value)) { | ||
f = getArrNestVals(name, value); | ||
} else if (type === 'object') { | ||
if (value !== null) { | ||
f = getObjNestVals(name, value); | ||
} else if (!optignorenull) { | ||
f = encode(name) + '=null'; | ||
} | ||
f = getObjNestVals(name, value); | ||
} | ||
@@ -74,6 +73,5 @@ | ||
// 5.1, http://www.w3.org/TR/html5/forms.html#url-encoded-form-data | ||
function manuallyEncodeChar (ch) { | ||
return '%' + ('0' + ch.charCodeAt(0).toString(16)).slice(-2).toUpperCase(); | ||
}; | ||
} | ||
@@ -85,3 +83,3 @@ function formEncodeString (value) { | ||
.replace(/[!'()~\*]/g, manuallyEncodeChar); | ||
}; | ||
} | ||
@@ -88,0 +86,0 @@ return getNestValsArrAsStr(getKeys(data).map(function (key) { |
{ | ||
"name": "form-urlencoded", | ||
"main": "form-urlencoded", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"author": "Chris <chris@bumblehead.com>", | ||
@@ -6,0 +6,0 @@ "license" : "MIT", |
@@ -175,2 +175,3 @@ var formurlencoded = require('../form-urlencoded'), | ||
}); | ||
}); |
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
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
13700
219