form-urlencoded
Advanced tools
@@ -49,3 +49,7 @@ // Filename: formurlencoded.js | ||
| return arr.length ? filterjoin(arr.map(function (elem, index) { | ||
| return nest(name + '[' + index + ']', elem); | ||
| if (opts.skipIndex) { | ||
| return nest(name + '[]', elem); | ||
| } else { | ||
| return nest(name + '[' + index + ']', elem); | ||
| } | ||
| })) : encode(name + '[]'); | ||
@@ -52,0 +56,0 @@ } |
+2
-2
| { | ||
| "name": "form-urlencoded", | ||
| "main": "form-urlencoded", | ||
| "version": "1.5.0", | ||
| "version": "1.5.1", | ||
| "description": "Return an object as an 'x-www-form-urlencoded' string", | ||
@@ -14,3 +14,3 @@ "author": "Chris <chris@bumblehead.com>", | ||
| "name": "Jumper423", | ||
| "email": "jump.e.r@yandex.ru" | ||
| "email": "jump.e.r@yandex.ru" | ||
| }], | ||
@@ -17,0 +17,0 @@ "repository": { |
@@ -158,2 +158,40 @@ // Filename: form-urlencoded.spec.js | ||
| it("should return encoded array inside an object with index", function() { | ||
| expect( | ||
| formurlencoded({ | ||
| parent: { | ||
| foo: 'bar', | ||
| emptyArr: ['first', 'second'] | ||
| } | ||
| }) | ||
| ).toBe( 'parent%5Bfoo%5D=bar&parent%5BemptyArr%5D%5B0%5D=first&parent%5BemptyArr%5D%5B1%5D=second' ); | ||
| }); | ||
| it("should return encoded array inside an object without index", function() { | ||
| expect( | ||
| formurlencoded({ | ||
| parent: { | ||
| foo: 'bar', | ||
| emptyArr: ['first', 'second'] | ||
| } | ||
| }, { skipIndex: true }) | ||
| ).toBe( 'parent%5Bfoo%5D=bar&parent%5BemptyArr%5D%5B%5D=first&parent%5BemptyArr%5D%5B%5D=second' ); | ||
| }); | ||
| it("should return array with index", function() { | ||
| expect( | ||
| formurlencoded({ | ||
| key: ['val1'] | ||
| }) | ||
| ).toBe( 'key%5B0%5D=val1' ) | ||
| }); | ||
| it("should return array without index", function() { | ||
| expect( | ||
| formurlencoded({ | ||
| key: ['val1'] | ||
| }, { skipIndex: true }) | ||
| ).toBe( 'key%5B%5D=val1' ) | ||
| }); | ||
| it("should return encoded urls with unicode characters", function() { | ||
@@ -160,0 +198,0 @@ expect( |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
14090
8.67%248
18.1%