File tree 3 files changed +9
-3
lines changed
3 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
+ var strictUriEncode = require ( 'strict-uri-encode' ) ;
4
+
3
5
exports . extract = function ( maybeUrl ) {
4
6
return maybeUrl . split ( '?' ) [ 1 ] || '' ;
5
7
} ;
@@ -43,10 +45,10 @@ exports.stringify = function (obj) {
43
45
44
46
if ( Array . isArray ( val ) ) {
45
47
return val . sort ( ) . map ( function ( val2 ) {
46
- return encodeURIComponent ( key ) + '=' + encodeURIComponent ( val2 ) ;
48
+ return strictUriEncode ( key ) + '=' + strictUriEncode ( val2 ) ;
47
49
} ) . join ( '&' ) ;
48
50
}
49
51
50
- return encodeURIComponent ( key ) + '=' + encodeURIComponent ( val ) ;
52
+ return strictUriEncode ( key ) + '=' + strictUriEncode ( val ) ;
51
53
} ) . join ( '&' ) : '' ;
52
54
} ;
Original file line number Diff line number Diff line change 35
35
},
36
36
"engines" : {
37
37
"node" : " >=0.10.0"
38
+ },
39
+ "dependencies" : {
40
+ "strict-uri-encode" : " ^1.0.0"
38
41
}
39
42
}
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