7
7
This module provides utilities for dealing with query strings.
8
8
It provides the following methods:
9
9
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
28
11
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.
35
14
36
15
## querystring.parse(str[ , sep] [ , eq ] [ , options] )
37
16
@@ -58,10 +37,31 @@ Example:
58
37
// returns
59
38
{ w: '中文', foo: 'bar' }
60
39
61
- ## querystring.escape
40
+ ## querystring.stringify(obj [ , sep ] [ , eq ] [ , options ] )
62
41
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'
65
65
66
66
## querystring.unescape
67
67
0 commit comments