blob: 30f41179ad3b95b43cc667b76dc5e8155f23f64f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
Module exports utility functions for working with query strings.
### stringify
Object may be serialize to a query string via exported `stringify` function:
querystring.stringify({ foo: 'bar', baz: 4 }); // => 'foo=bar&baz=4'
Optionally `separator` and `assignment` arguments may be passed to
override default `'&'` and`'='` characters:
querystring.stringify({ foo: 'bar', baz: 4 }, ';', ':'); // => 'foo:bar;baz:4'
### parse
Query string may be deserialized to an object via exported `parse`
function:
querystring.parse('foo=bar&baz=bla') // => { foo: 'bar', baz: 'bla' }
Optionally `separator` and `assignment` arguments may be passed to
override default `'&'` and `'='` characters:
querystring.parse('foo:bar|baz:bla', '|', ':') // => { foo: 'bar', baz: 'bla' }
### escape
The escape function used by `stringify` to encodes a string safely
matching RFC 3986 for `application/x-www-form-urlencoded`.
### unescape
The unescape function used by `parse` to decode a string safely.
|