77This module provides utilities for dealing with query strings.
88It provides the following methods:
99
10- ## querystring.stringify(obj[ , sep] [ , eq ] [ , options] )
11-
12- Serialize an object to a query string.
13- Optionally override the default separator (` '&' ` ) and assignment (` '=' ` )
14- characters.
15-
16- Options object may contain ` encodeURIComponent ` property (` querystring.escape ` by default),
17- it can be used to encode string with ` non-utf8 ` encoding if necessary.
18-
19- Example:
20-
21- querystring.stringify({ foo: 'bar', baz: ['qux', 'quux'], corge: '' })
22- // returns
23- 'foo=bar&baz=qux&baz=quux&corge='
24-
25- querystring.stringify({foo: 'bar', baz: 'qux'}, ';', ':')
26- // returns
27- 'foo:bar;baz:qux'
10+ ## querystring.escape
2811
29- // Suppose gbkEncodeURIComponent function already exists,
30- // it can encode string with `gbk` encoding
31- querystring.stringify({ w: '中文', foo: 'bar' }, null, null,
32- { encodeURIComponent: gbkEncodeURIComponent })
33- // returns
34- 'w=%D6%D0%CE%C4&foo=bar'
12+ The escape function used by ` querystring.stringify ` ,
13+ provided so that it could be overridden if necessary.
3514
3615## querystring.parse(str[ , sep] [ , eq ] [ , options] )
3716
@@ -58,10 +37,31 @@ Example:
5837 // returns
5938 { w: '中文', foo: 'bar' }
6039
61- ## querystring.escape
40+ ## querystring.stringify(obj [ , sep ] [ , eq ] [ , options ] )
6241
63- The escape function used by ` querystring.stringify ` ,
64- provided so that it could be overridden if necessary.
42+ Serialize an object to a query string.
43+ Optionally override the default separator (` '&' ` ) and assignment (` '=' ` )
44+ characters.
45+
46+ Options object may contain ` encodeURIComponent ` property (` querystring.escape ` by default),
47+ it can be used to encode string with ` non-utf8 ` encoding if necessary.
48+
49+ Example:
50+
51+ querystring.stringify({ foo: 'bar', baz: ['qux', 'quux'], corge: '' })
52+ // returns
53+ 'foo=bar&baz=qux&baz=quux&corge='
54+
55+ querystring.stringify({foo: 'bar', baz: 'qux'}, ';', ':')
56+ // returns
57+ 'foo:bar;baz:qux'
58+
59+ // Suppose gbkEncodeURIComponent function already exists,
60+ // it can encode string with `gbk` encoding
61+ querystring.stringify({ w: '中文', foo: 'bar' }, null, null,
62+ { encodeURIComponent: gbkEncodeURIComponent })
63+ // returns
64+ 'w=%D6%D0%CE%C4&foo=bar'
6565
6666## querystring.unescape
6767
0 commit comments