diff options
author | Robert Jefe Lindstaedt <robert.lindstaedt@gmail.com> | 2016-04-21 00:12:40 +0200 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2016-04-20 16:34:27 -0700 |
commit | 0800c0aa7275bf389b157e1568fa61b59285ad86 (patch) | |
tree | a0b739491c4b0170fc333b1b57d61e6d7ae1ca58 /doc/api/querystring.md | |
parent | cff2a137f201604cbb3c4e54578b4ebfd20bcaf2 (diff) | |
download | android-node-v8-0800c0aa7275bf389b157e1568fa61b59285ad86.tar.gz android-node-v8-0800c0aa7275bf389b157e1568fa61b59285ad86.tar.bz2 android-node-v8-0800c0aa7275bf389b157e1568fa61b59285ad86.zip |
doc: git mv to .md
* doc: rename .markdown references in content
* doc: rename to .md in tools
* doc: rename to .md in CONTRIBUTING.md
PR-URL: https://github.com/nodejs/node/pull/4747
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: techjeffharris
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'doc/api/querystring.md')
-rw-r--r-- | doc/api/querystring.md | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/doc/api/querystring.md b/doc/api/querystring.md new file mode 100644 index 0000000000..3a864e2d4f --- /dev/null +++ b/doc/api/querystring.md @@ -0,0 +1,72 @@ +# Query String + + Stability: 2 - Stable + +<!--name=querystring--> + +This module provides utilities for dealing with query strings. +It provides the following methods: + +## querystring.escape + +The escape function used by `querystring.stringify`, +provided so that it could be overridden if necessary. + +## querystring.parse(str[, sep][, eq][, options]) + +Deserialize a query string to an object. +Optionally override the default separator (`'&'`) and assignment (`'='`) +characters. + +Options object may contain `maxKeys` property (equal to 1000 by default), it'll +be used to limit processed keys. Set it to 0 to remove key count limitation. + +Options object may contain `decodeURIComponent` property (`querystring.unescape` by default), +it can be used to decode a `non-utf8` encoding string if necessary. + +Example: + +```js +querystring.parse('foo=bar&baz=qux&baz=quux&corge') +// returns { foo: 'bar', baz: ['qux', 'quux'], corge: '' } + +// Suppose gbkDecodeURIComponent function already exists, +// it can decode `gbk` encoding string +querystring.parse('w=%D6%D0%CE%C4&foo=bar', null, null, + { decodeURIComponent: gbkDecodeURIComponent }) +// returns { w: '中文', foo: 'bar' } +``` + +## querystring.stringify(obj[, sep][, eq][, options]) + +Serialize an object to a query string. +Optionally override the default separator (`'&'`) and assignment (`'='`) +characters. + +Options object may contain `encodeURIComponent` property (`querystring.escape` by default), +it can be used to encode string with `non-utf8` encoding if necessary. + +Example: + +```js +querystring.stringify({ foo: 'bar', baz: ['qux', 'quux'], corge: '' }) +// returns 'foo=bar&baz=qux&baz=quux&corge=' + +querystring.stringify({foo: 'bar', baz: 'qux'}, ';', ':') +// returns 'foo:bar;baz:qux' + +// Suppose gbkEncodeURIComponent function already exists, +// it can encode string with `gbk` encoding +querystring.stringify({ w: '中文', foo: 'bar' }, null, null, + { encodeURIComponent: gbkEncodeURIComponent }) +// returns 'w=%D6%D0%CE%C4&foo=bar' +``` + +## querystring.unescape + +The unescape function used by `querystring.parse`, +provided so that it could be overridden if necessary. + +It will try to use `decodeURIComponent` in the first place, +but if that fails it falls back to a safer equivalent that +doesn't throw on malformed URLs. |