File tree 3 files changed +8
-3
lines changed
3 files changed +8
-3
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
+ var strictUriEncode = require ( 'strict-uri-encode' ) ;
2
3
3
4
exports . extract = function ( maybeUrl ) {
4
5
return maybeUrl . split ( '?' ) [ 1 ] || '' ;
@@ -43,10 +44,10 @@ exports.stringify = function (obj) {
43
44
44
45
if ( Array . isArray ( val ) ) {
45
46
return val . sort ( ) . map ( function ( val2 ) {
46
- return encodeURIComponent ( key ) + '=' + encodeURIComponent ( val2 ) ;
47
+ return strictUriEncode ( key ) + '=' + strictUriEncode ( val2 ) ;
47
48
} ) . join ( '&' ) ;
48
49
}
49
50
50
- return encodeURIComponent ( key ) + '=' + encodeURIComponent ( val ) ;
51
+ return strictUriEncode ( key ) + '=' + strictUriEncode ( val ) ;
51
52
} ) . join ( '&' ) : '' ;
52
53
} ;
Original file line number Diff line number Diff line change 30
30
"scripts" : {
31
31
"test" : " mocha"
32
32
},
33
+ "dependencies" : {
34
+ "strict-uri-encode" : " ^1.0.0"
35
+ },
33
36
"devDependencies" : {
34
37
"mocha" : " *"
35
38
},
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ describe('.stringify()', function () {
62
62
63
63
it ( 'URI encode' , function ( ) {
64
64
assert . strictEqual ( qs . stringify ( { 'foo bar' : 'baz faz' } ) , 'foo%20bar=baz%20faz' ) ;
65
+ assert . strictEqual ( qs . stringify ( { 'foo bar' : "baz'faz" } ) , 'foo%20bar=baz%27faz' ) ;
65
66
} ) ;
66
67
67
68
it ( 'handle array value' , function ( ) {
@@ -88,4 +89,4 @@ describe('.extract()', function () {
88
89
qs . extract ( undefined ) ;
89
90
} , TypeError ) ;
90
91
} ) ;
91
- } ) ;
92
+ } ) ;
You can’t perform that action at this time.
0 commit comments