es6-crawler-detect 3.1.1 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +2 -1
- package/.eslintignore +6 -0
- package/.eslintrc.json +30 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +11 -8
- package/.github/ISSUE_TEMPLATE/feature_request.md +1 -1
- package/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +29 -0
- package/.prettierrc.json +5 -0
- package/README.md +27 -17
- package/dist/main.bundle.js +1 -1
- package/example/node/dist/crawler.min.js +1 -1
- package/example/node/node_modules/.bin/mime +15 -0
- package/example/node/node_modules/.bin/mime.cmd +7 -0
- package/example/node/node_modules/.yarn-integrity +67 -0
- package/example/node/node_modules/accepts/HISTORY.md +236 -0
- package/example/node/node_modules/accepts/LICENSE +23 -0
- package/example/node/node_modules/accepts/README.md +142 -0
- package/example/node/node_modules/accepts/index.js +238 -0
- package/example/node/node_modules/accepts/package.json +47 -0
- package/example/node/node_modules/array-flatten/LICENSE +21 -0
- package/example/node/node_modules/array-flatten/README.md +43 -0
- package/example/node/node_modules/array-flatten/array-flatten.js +64 -0
- package/example/node/node_modules/array-flatten/package.json +39 -0
- package/example/node/node_modules/body-parser/HISTORY.md +624 -0
- package/example/node/node_modules/body-parser/LICENSE +23 -0
- package/example/node/node_modules/body-parser/README.md +456 -0
- package/example/node/node_modules/body-parser/index.js +157 -0
- package/example/node/node_modules/body-parser/lib/read.js +181 -0
- package/example/node/node_modules/body-parser/lib/types/json.js +230 -0
- package/example/node/node_modules/body-parser/lib/types/raw.js +101 -0
- package/example/node/node_modules/body-parser/lib/types/text.js +121 -0
- package/example/node/node_modules/body-parser/lib/types/urlencoded.js +284 -0
- package/example/node/node_modules/body-parser/package.json +52 -0
- package/example/node/node_modules/bytes/History.md +92 -0
- package/example/node/node_modules/bytes/LICENSE +23 -0
- package/example/node/node_modules/bytes/Readme.md +152 -0
- package/example/node/node_modules/bytes/index.js +166 -0
- package/example/node/node_modules/bytes/package.json +42 -0
- package/example/node/node_modules/content-disposition/HISTORY.md +60 -0
- package/example/node/node_modules/content-disposition/LICENSE +22 -0
- package/example/node/node_modules/content-disposition/README.md +142 -0
- package/example/node/node_modules/content-disposition/index.js +458 -0
- package/example/node/node_modules/content-disposition/package.json +44 -0
- package/example/node/node_modules/content-type/HISTORY.md +24 -0
- package/example/node/node_modules/content-type/LICENSE +22 -0
- package/example/node/node_modules/content-type/README.md +92 -0
- package/example/node/node_modules/content-type/index.js +222 -0
- package/example/node/node_modules/content-type/package.json +40 -0
- package/example/node/node_modules/cookie/HISTORY.md +128 -0
- package/example/node/node_modules/cookie/LICENSE +24 -0
- package/example/node/node_modules/cookie/README.md +257 -0
- package/example/node/node_modules/cookie/index.js +202 -0
- package/example/node/node_modules/cookie/package.json +40 -0
- package/example/node/node_modules/cookie-signature/History.md +38 -0
- package/example/node/node_modules/cookie-signature/Readme.md +42 -0
- package/example/node/node_modules/cookie-signature/index.js +51 -0
- package/example/node/node_modules/cookie-signature/package.json +18 -0
- package/example/node/node_modules/debug/.coveralls.yml +1 -0
- package/example/node/node_modules/debug/.eslintrc +11 -0
- package/example/node/node_modules/debug/.travis.yml +14 -0
- package/example/node/node_modules/debug/CHANGELOG.md +362 -0
- package/example/node/node_modules/debug/LICENSE +19 -0
- package/example/node/node_modules/debug/Makefile +50 -0
- package/example/node/node_modules/debug/README.md +312 -0
- package/example/node/node_modules/debug/component.json +19 -0
- package/example/node/node_modules/debug/karma.conf.js +70 -0
- package/example/node/node_modules/debug/node.js +1 -0
- package/example/node/node_modules/debug/package.json +49 -0
- package/example/node/node_modules/debug/src/browser.js +185 -0
- package/example/node/node_modules/debug/src/debug.js +202 -0
- package/example/node/node_modules/debug/src/index.js +10 -0
- package/example/node/node_modules/debug/src/inspector-log.js +15 -0
- package/example/node/node_modules/debug/src/node.js +248 -0
- package/example/node/node_modules/depd/History.md +96 -0
- package/example/node/node_modules/depd/LICENSE +22 -0
- package/example/node/node_modules/depd/Readme.md +280 -0
- package/example/node/node_modules/depd/index.js +522 -0
- package/example/node/node_modules/depd/lib/browser/index.js +77 -0
- package/example/node/node_modules/depd/lib/compat/callsite-tostring.js +103 -0
- package/example/node/node_modules/depd/lib/compat/event-listener-count.js +22 -0
- package/example/node/node_modules/depd/lib/compat/index.js +79 -0
- package/example/node/node_modules/depd/package.json +41 -0
- package/example/node/node_modules/destroy/LICENSE +22 -0
- package/example/node/node_modules/destroy/README.md +60 -0
- package/example/node/node_modules/destroy/index.js +75 -0
- package/example/node/node_modules/destroy/package.json +37 -0
- package/example/node/node_modules/ee-first/LICENSE +22 -0
- package/example/node/node_modules/ee-first/README.md +80 -0
- package/example/node/node_modules/ee-first/index.js +95 -0
- package/example/node/node_modules/ee-first/package.json +29 -0
- package/example/node/node_modules/encodeurl/HISTORY.md +14 -0
- package/example/node/node_modules/encodeurl/LICENSE +22 -0
- package/example/node/node_modules/encodeurl/README.md +128 -0
- package/example/node/node_modules/encodeurl/index.js +60 -0
- package/example/node/node_modules/encodeurl/package.json +40 -0
- package/example/node/node_modules/escape-html/LICENSE +24 -0
- package/example/node/node_modules/escape-html/Readme.md +43 -0
- package/example/node/node_modules/escape-html/index.js +78 -0
- package/example/node/node_modules/escape-html/package.json +24 -0
- package/example/node/node_modules/etag/HISTORY.md +83 -0
- package/example/node/node_modules/etag/LICENSE +22 -0
- package/example/node/node_modules/etag/README.md +159 -0
- package/example/node/node_modules/etag/index.js +131 -0
- package/example/node/node_modules/etag/package.json +47 -0
- package/example/node/node_modules/express/History.md +3510 -0
- package/example/node/node_modules/express/LICENSE +24 -0
- package/example/node/node_modules/express/Readme.md +158 -0
- package/example/node/node_modules/express/index.js +11 -0
- package/example/node/node_modules/express/lib/application.js +644 -0
- package/example/node/node_modules/express/lib/express.js +116 -0
- package/example/node/node_modules/express/lib/middleware/init.js +43 -0
- package/example/node/node_modules/express/lib/middleware/query.js +47 -0
- package/example/node/node_modules/express/lib/request.js +525 -0
- package/example/node/node_modules/express/lib/response.js +1147 -0
- package/example/node/node_modules/express/lib/router/index.js +668 -0
- package/example/node/node_modules/express/lib/router/layer.js +181 -0
- package/example/node/node_modules/express/lib/router/route.js +216 -0
- package/example/node/node_modules/express/lib/utils.js +302 -0
- package/example/node/node_modules/express/lib/view.js +182 -0
- package/example/node/node_modules/express/package.json +99 -0
- package/example/node/node_modules/finalhandler/HISTORY.md +187 -0
- package/example/node/node_modules/finalhandler/LICENSE +22 -0
- package/example/node/node_modules/finalhandler/README.md +148 -0
- package/example/node/node_modules/finalhandler/index.js +331 -0
- package/example/node/node_modules/finalhandler/package.json +45 -0
- package/example/node/node_modules/forwarded/HISTORY.md +21 -0
- package/example/node/node_modules/forwarded/LICENSE +22 -0
- package/example/node/node_modules/forwarded/README.md +57 -0
- package/example/node/node_modules/forwarded/index.js +90 -0
- package/example/node/node_modules/forwarded/package.json +45 -0
- package/example/node/node_modules/fresh/HISTORY.md +70 -0
- package/example/node/node_modules/fresh/LICENSE +23 -0
- package/example/node/node_modules/fresh/README.md +119 -0
- package/example/node/node_modules/fresh/index.js +137 -0
- package/example/node/node_modules/fresh/package.json +46 -0
- package/example/node/node_modules/http-errors/HISTORY.md +165 -0
- package/example/node/node_modules/http-errors/LICENSE +23 -0
- package/example/node/node_modules/http-errors/README.md +169 -0
- package/example/node/node_modules/http-errors/index.js +299 -0
- package/example/node/node_modules/http-errors/package.json +49 -0
- package/example/node/node_modules/iconv-lite/Changelog.md +162 -0
- package/example/node/node_modules/iconv-lite/LICENSE +21 -0
- package/example/node/node_modules/iconv-lite/README.md +156 -0
- package/example/node/node_modules/iconv-lite/encodings/dbcs-codec.js +555 -0
- package/example/node/node_modules/iconv-lite/encodings/dbcs-data.js +176 -0
- package/example/node/node_modules/iconv-lite/encodings/index.js +22 -0
- package/example/node/node_modules/iconv-lite/encodings/internal.js +188 -0
- package/example/node/node_modules/iconv-lite/encodings/sbcs-codec.js +72 -0
- package/example/node/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
- package/example/node/node_modules/iconv-lite/encodings/sbcs-data.js +174 -0
- package/example/node/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
- package/example/node/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
- package/example/node/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
- package/example/node/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
- package/example/node/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
- package/example/node/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
- package/example/node/node_modules/iconv-lite/encodings/tables/gbk-added.json +55 -0
- package/example/node/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
- package/example/node/node_modules/iconv-lite/encodings/utf16.js +177 -0
- package/example/node/node_modules/iconv-lite/encodings/utf7.js +290 -0
- package/example/node/node_modules/iconv-lite/lib/bom-handling.js +52 -0
- package/example/node/node_modules/iconv-lite/lib/extend-node.js +217 -0
- package/example/node/node_modules/iconv-lite/lib/index.d.ts +24 -0
- package/example/node/node_modules/iconv-lite/lib/index.js +153 -0
- package/example/node/node_modules/iconv-lite/lib/streams.js +121 -0
- package/example/node/node_modules/iconv-lite/package.json +46 -0
- package/example/node/node_modules/inherits/LICENSE +16 -0
- package/example/node/node_modules/inherits/README.md +42 -0
- package/example/node/node_modules/inherits/inherits.js +9 -0
- package/example/node/node_modules/inherits/inherits_browser.js +27 -0
- package/example/node/node_modules/inherits/package.json +29 -0
- package/example/node/node_modules/ipaddr.js/LICENSE +19 -0
- package/example/node/node_modules/ipaddr.js/README.md +233 -0
- package/example/node/node_modules/ipaddr.js/ipaddr.min.js +1 -0
- package/example/node/node_modules/ipaddr.js/lib/ipaddr.js +673 -0
- package/example/node/node_modules/ipaddr.js/lib/ipaddr.js.d.ts +68 -0
- package/example/node/node_modules/ipaddr.js/package.json +35 -0
- package/example/node/node_modules/media-typer/HISTORY.md +22 -0
- package/example/node/node_modules/media-typer/LICENSE +22 -0
- package/example/node/node_modules/media-typer/README.md +81 -0
- package/example/node/node_modules/media-typer/index.js +270 -0
- package/example/node/node_modules/media-typer/package.json +26 -0
- package/example/node/node_modules/merge-descriptors/HISTORY.md +21 -0
- package/example/node/node_modules/merge-descriptors/LICENSE +23 -0
- package/example/node/node_modules/merge-descriptors/README.md +48 -0
- package/example/node/node_modules/merge-descriptors/index.js +60 -0
- package/example/node/node_modules/merge-descriptors/package.json +32 -0
- package/example/node/node_modules/methods/HISTORY.md +29 -0
- package/example/node/node_modules/methods/LICENSE +24 -0
- package/example/node/node_modules/methods/README.md +51 -0
- package/example/node/node_modules/methods/index.js +69 -0
- package/example/node/node_modules/methods/package.json +36 -0
- package/example/node/node_modules/mime/CHANGELOG.md +164 -0
- package/example/node/node_modules/mime/LICENSE +21 -0
- package/example/node/node_modules/mime/README.md +90 -0
- package/example/node/node_modules/mime/cli.js +8 -0
- package/example/node/node_modules/mime/mime.js +108 -0
- package/example/node/node_modules/mime/package.json +44 -0
- package/example/node/node_modules/mime/src/build.js +53 -0
- package/example/node/node_modules/mime/src/test.js +60 -0
- package/example/node/node_modules/mime/types.json +1 -0
- package/example/node/node_modules/mime-db/HISTORY.md +499 -0
- package/example/node/node_modules/mime-db/LICENSE +22 -0
- package/example/node/node_modules/mime-db/README.md +100 -0
- package/example/node/node_modules/mime-db/db.json +8471 -0
- package/example/node/node_modules/mime-db/index.js +11 -0
- package/example/node/node_modules/mime-db/package.json +59 -0
- package/example/node/node_modules/mime-types/HISTORY.md +388 -0
- package/example/node/node_modules/mime-types/LICENSE +23 -0
- package/example/node/node_modules/mime-types/README.md +113 -0
- package/example/node/node_modules/mime-types/index.js +188 -0
- package/example/node/node_modules/mime-types/package.json +44 -0
- package/example/node/node_modules/ms/index.js +152 -0
- package/example/node/node_modules/ms/license.md +21 -0
- package/example/node/node_modules/ms/package.json +37 -0
- package/example/node/node_modules/ms/readme.md +51 -0
- package/example/node/node_modules/negotiator/HISTORY.md +103 -0
- package/example/node/node_modules/negotiator/LICENSE +24 -0
- package/example/node/node_modules/negotiator/README.md +203 -0
- package/example/node/node_modules/negotiator/index.js +124 -0
- package/example/node/node_modules/negotiator/lib/charset.js +169 -0
- package/example/node/node_modules/negotiator/lib/encoding.js +184 -0
- package/example/node/node_modules/negotiator/lib/language.js +179 -0
- package/example/node/node_modules/negotiator/lib/mediaType.js +294 -0
- package/example/node/node_modules/negotiator/package.json +42 -0
- package/example/node/node_modules/on-finished/HISTORY.md +88 -0
- package/example/node/node_modules/on-finished/LICENSE +23 -0
- package/example/node/node_modules/on-finished/README.md +154 -0
- package/example/node/node_modules/on-finished/index.js +196 -0
- package/example/node/node_modules/on-finished/package.json +31 -0
- package/example/node/node_modules/parseurl/HISTORY.md +58 -0
- package/example/node/node_modules/parseurl/LICENSE +24 -0
- package/example/node/node_modules/parseurl/README.md +133 -0
- package/example/node/node_modules/parseurl/index.js +158 -0
- package/example/node/node_modules/parseurl/package.json +40 -0
- package/example/node/node_modules/path-to-regexp/History.md +36 -0
- package/example/node/node_modules/path-to-regexp/LICENSE +21 -0
- package/example/node/node_modules/path-to-regexp/Readme.md +35 -0
- package/example/node/node_modules/path-to-regexp/index.js +129 -0
- package/example/node/node_modules/path-to-regexp/package.json +30 -0
- package/example/node/node_modules/proxy-addr/HISTORY.md +161 -0
- package/example/node/node_modules/proxy-addr/LICENSE +22 -0
- package/example/node/node_modules/proxy-addr/README.md +139 -0
- package/example/node/node_modules/proxy-addr/index.js +327 -0
- package/example/node/node_modules/proxy-addr/package.json +47 -0
- package/example/node/node_modules/qs/.editorconfig +39 -0
- package/example/node/node_modules/qs/.eslintignore +2 -0
- package/example/node/node_modules/qs/.eslintrc +35 -0
- package/example/node/node_modules/qs/.github/FUNDING.yml +12 -0
- package/example/node/node_modules/qs/.nycrc +13 -0
- package/example/node/node_modules/qs/CHANGELOG.md +359 -0
- package/example/node/node_modules/qs/LICENSE.md +29 -0
- package/example/node/node_modules/qs/README.md +604 -0
- package/example/node/node_modules/qs/dist/qs.js +832 -0
- package/example/node/node_modules/qs/lib/formats.js +23 -0
- package/example/node/node_modules/qs/lib/index.js +11 -0
- package/example/node/node_modules/qs/lib/parse.js +257 -0
- package/example/node/node_modules/qs/lib/stringify.js +278 -0
- package/example/node/node_modules/qs/lib/utils.js +251 -0
- package/example/node/node_modules/qs/package.json +69 -0
- package/example/node/node_modules/qs/test/parse.js +772 -0
- package/example/node/node_modules/qs/test/stringify.js +793 -0
- package/example/node/node_modules/qs/test/utils.js +136 -0
- package/example/node/node_modules/range-parser/HISTORY.md +56 -0
- package/example/node/node_modules/range-parser/LICENSE +23 -0
- package/example/node/node_modules/range-parser/README.md +84 -0
- package/example/node/node_modules/range-parser/index.js +162 -0
- package/example/node/node_modules/range-parser/package.json +44 -0
- package/example/node/node_modules/raw-body/HISTORY.md +284 -0
- package/example/node/node_modules/raw-body/LICENSE +22 -0
- package/example/node/node_modules/raw-body/README.md +217 -0
- package/example/node/node_modules/raw-body/index.d.ts +87 -0
- package/example/node/node_modules/raw-body/index.js +286 -0
- package/example/node/node_modules/raw-body/package.json +48 -0
- package/example/node/node_modules/safe-buffer/LICENSE +21 -0
- package/example/node/node_modules/safe-buffer/README.md +584 -0
- package/example/node/node_modules/safe-buffer/index.d.ts +187 -0
- package/example/node/node_modules/safe-buffer/index.js +65 -0
- package/example/node/node_modules/safe-buffer/package.json +51 -0
- package/example/node/node_modules/safer-buffer/LICENSE +21 -0
- package/example/node/node_modules/safer-buffer/Porting-Buffer.md +268 -0
- package/example/node/node_modules/safer-buffer/Readme.md +156 -0
- package/example/node/node_modules/safer-buffer/dangerous.js +58 -0
- package/example/node/node_modules/safer-buffer/package.json +34 -0
- package/example/node/node_modules/safer-buffer/safer.js +77 -0
- package/example/node/node_modules/safer-buffer/tests.js +406 -0
- package/example/node/node_modules/send/HISTORY.md +506 -0
- package/example/node/node_modules/send/LICENSE +23 -0
- package/example/node/node_modules/send/README.md +327 -0
- package/example/node/node_modules/send/index.js +1133 -0
- package/example/node/node_modules/send/node_modules/.bin/mime +15 -0
- package/example/node/node_modules/send/node_modules/.bin/mime.cmd +7 -0
- package/example/node/node_modules/send/node_modules/ms/index.js +162 -0
- package/example/node/node_modules/send/node_modules/ms/license.md +21 -0
- package/example/node/node_modules/send/node_modules/ms/package.json +38 -0
- package/example/node/node_modules/send/node_modules/ms/readme.md +59 -0
- package/example/node/node_modules/send/package.json +61 -0
- package/example/node/node_modules/serve-static/HISTORY.md +459 -0
- package/example/node/node_modules/serve-static/LICENSE +25 -0
- package/example/node/node_modules/serve-static/README.md +257 -0
- package/example/node/node_modules/serve-static/index.js +210 -0
- package/example/node/node_modules/serve-static/package.json +42 -0
- package/example/node/node_modules/setprototypeof/LICENSE +13 -0
- package/example/node/node_modules/setprototypeof/README.md +31 -0
- package/example/node/node_modules/setprototypeof/index.d.ts +2 -0
- package/example/node/node_modules/setprototypeof/index.js +17 -0
- package/example/node/node_modules/setprototypeof/package.json +38 -0
- package/example/node/node_modules/setprototypeof/test/index.js +24 -0
- package/example/node/node_modules/statuses/HISTORY.md +65 -0
- package/example/node/node_modules/statuses/LICENSE +23 -0
- package/example/node/node_modules/statuses/README.md +127 -0
- package/example/node/node_modules/statuses/codes.json +66 -0
- package/example/node/node_modules/statuses/index.js +113 -0
- package/example/node/node_modules/statuses/package.json +48 -0
- package/example/node/node_modules/toidentifier/HISTORY.md +9 -0
- package/example/node/node_modules/toidentifier/LICENSE +21 -0
- package/example/node/node_modules/toidentifier/README.md +61 -0
- package/example/node/node_modules/toidentifier/index.js +32 -0
- package/example/node/node_modules/toidentifier/package.json +38 -0
- package/example/node/node_modules/type-is/HISTORY.md +259 -0
- package/example/node/node_modules/type-is/LICENSE +23 -0
- package/example/node/node_modules/type-is/README.md +170 -0
- package/example/node/node_modules/type-is/index.js +266 -0
- package/example/node/node_modules/type-is/package.json +45 -0
- package/example/node/node_modules/unpipe/HISTORY.md +4 -0
- package/example/node/node_modules/unpipe/LICENSE +22 -0
- package/example/node/node_modules/unpipe/README.md +43 -0
- package/example/node/node_modules/unpipe/index.js +69 -0
- package/example/node/node_modules/unpipe/package.json +27 -0
- package/example/node/node_modules/utils-merge/LICENSE +20 -0
- package/example/node/node_modules/utils-merge/README.md +34 -0
- package/example/node/node_modules/utils-merge/index.js +23 -0
- package/example/node/node_modules/utils-merge/package.json +40 -0
- package/example/node/node_modules/vary/HISTORY.md +39 -0
- package/example/node/node_modules/vary/LICENSE +22 -0
- package/example/node/node_modules/vary/README.md +101 -0
- package/example/node/node_modules/vary/index.js +149 -0
- package/example/node/node_modules/vary/package.json +43 -0
- package/example/node/package.json +11 -0
- package/example/node/server.js +27 -15
- package/example/node/yarn.lock +352 -0
- package/package.json +29 -18
- package/src/index.js +16 -10
- package/src/lib/crawler/crawlers.js +1399 -11
- package/src/lib/crawler/exclusions.js +56 -9
- package/src/lib/crawler/headers.js +24 -15
- package/src/lib/crawler/provider.js +11 -13
- package/src/lib/crawler.js +123 -132
- package/test/lib/crawler.test.js +83 -24
- package/test/lib/database/crawlers.txt +3651 -0
- package/test/lib/database/devices.txt +165636 -0
- package/webpack.common.js +20 -20
- package/webpack.dev.js +7 -7
- package/webpack.prod.js +14 -15
@@ -0,0 +1,772 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var test = require('tape');
|
4
|
+
var qs = require('../');
|
5
|
+
var utils = require('../lib/utils');
|
6
|
+
var iconv = require('iconv-lite');
|
7
|
+
var SaferBuffer = require('safer-buffer').Buffer;
|
8
|
+
|
9
|
+
test('parse()', function (t) {
|
10
|
+
t.test('parses a simple string', function (st) {
|
11
|
+
st.deepEqual(qs.parse('0=foo'), { 0: 'foo' });
|
12
|
+
st.deepEqual(qs.parse('foo=c++'), { foo: 'c ' });
|
13
|
+
st.deepEqual(qs.parse('a[>=]=23'), { a: { '>=': '23' } });
|
14
|
+
st.deepEqual(qs.parse('a[<=>]==23'), { a: { '<=>': '=23' } });
|
15
|
+
st.deepEqual(qs.parse('a[==]=23'), { a: { '==': '23' } });
|
16
|
+
st.deepEqual(qs.parse('foo', { strictNullHandling: true }), { foo: null });
|
17
|
+
st.deepEqual(qs.parse('foo'), { foo: '' });
|
18
|
+
st.deepEqual(qs.parse('foo='), { foo: '' });
|
19
|
+
st.deepEqual(qs.parse('foo=bar'), { foo: 'bar' });
|
20
|
+
st.deepEqual(qs.parse(' foo = bar = baz '), { ' foo ': ' bar = baz ' });
|
21
|
+
st.deepEqual(qs.parse('foo=bar=baz'), { foo: 'bar=baz' });
|
22
|
+
st.deepEqual(qs.parse('foo=bar&bar=baz'), { foo: 'bar', bar: 'baz' });
|
23
|
+
st.deepEqual(qs.parse('foo2=bar2&baz2='), { foo2: 'bar2', baz2: '' });
|
24
|
+
st.deepEqual(qs.parse('foo=bar&baz', { strictNullHandling: true }), { foo: 'bar', baz: null });
|
25
|
+
st.deepEqual(qs.parse('foo=bar&baz'), { foo: 'bar', baz: '' });
|
26
|
+
st.deepEqual(qs.parse('cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World'), {
|
27
|
+
cht: 'p3',
|
28
|
+
chd: 't:60,40',
|
29
|
+
chs: '250x100',
|
30
|
+
chl: 'Hello|World'
|
31
|
+
});
|
32
|
+
st.end();
|
33
|
+
});
|
34
|
+
|
35
|
+
t.test('arrayFormat: brackets allows only explicit arrays', function (st) {
|
36
|
+
st.deepEqual(qs.parse('a[]=b&a[]=c', { arrayFormat: 'brackets' }), { a: ['b', 'c'] });
|
37
|
+
st.deepEqual(qs.parse('a[0]=b&a[1]=c', { arrayFormat: 'brackets' }), { a: ['b', 'c'] });
|
38
|
+
st.deepEqual(qs.parse('a=b,c', { arrayFormat: 'brackets' }), { a: 'b,c' });
|
39
|
+
st.deepEqual(qs.parse('a=b&a=c', { arrayFormat: 'brackets' }), { a: ['b', 'c'] });
|
40
|
+
st.end();
|
41
|
+
});
|
42
|
+
|
43
|
+
t.test('arrayFormat: indices allows only indexed arrays', function (st) {
|
44
|
+
st.deepEqual(qs.parse('a[]=b&a[]=c', { arrayFormat: 'indices' }), { a: ['b', 'c'] });
|
45
|
+
st.deepEqual(qs.parse('a[0]=b&a[1]=c', { arrayFormat: 'indices' }), { a: ['b', 'c'] });
|
46
|
+
st.deepEqual(qs.parse('a=b,c', { arrayFormat: 'indices' }), { a: 'b,c' });
|
47
|
+
st.deepEqual(qs.parse('a=b&a=c', { arrayFormat: 'indices' }), { a: ['b', 'c'] });
|
48
|
+
st.end();
|
49
|
+
});
|
50
|
+
|
51
|
+
t.test('arrayFormat: comma allows only comma-separated arrays', function (st) {
|
52
|
+
st.deepEqual(qs.parse('a[]=b&a[]=c', { arrayFormat: 'comma' }), { a: ['b', 'c'] });
|
53
|
+
st.deepEqual(qs.parse('a[0]=b&a[1]=c', { arrayFormat: 'comma' }), { a: ['b', 'c'] });
|
54
|
+
st.deepEqual(qs.parse('a=b,c', { arrayFormat: 'comma' }), { a: 'b,c' });
|
55
|
+
st.deepEqual(qs.parse('a=b&a=c', { arrayFormat: 'comma' }), { a: ['b', 'c'] });
|
56
|
+
st.end();
|
57
|
+
});
|
58
|
+
|
59
|
+
t.test('arrayFormat: repeat allows only repeated values', function (st) {
|
60
|
+
st.deepEqual(qs.parse('a[]=b&a[]=c', { arrayFormat: 'repeat' }), { a: ['b', 'c'] });
|
61
|
+
st.deepEqual(qs.parse('a[0]=b&a[1]=c', { arrayFormat: 'repeat' }), { a: ['b', 'c'] });
|
62
|
+
st.deepEqual(qs.parse('a=b,c', { arrayFormat: 'repeat' }), { a: 'b,c' });
|
63
|
+
st.deepEqual(qs.parse('a=b&a=c', { arrayFormat: 'repeat' }), { a: ['b', 'c'] });
|
64
|
+
st.end();
|
65
|
+
});
|
66
|
+
|
67
|
+
t.test('allows enabling dot notation', function (st) {
|
68
|
+
st.deepEqual(qs.parse('a.b=c'), { 'a.b': 'c' });
|
69
|
+
st.deepEqual(qs.parse('a.b=c', { allowDots: true }), { a: { b: 'c' } });
|
70
|
+
st.end();
|
71
|
+
});
|
72
|
+
|
73
|
+
t.deepEqual(qs.parse('a[b]=c'), { a: { b: 'c' } }, 'parses a single nested string');
|
74
|
+
t.deepEqual(qs.parse('a[b][c]=d'), { a: { b: { c: 'd' } } }, 'parses a double nested string');
|
75
|
+
t.deepEqual(
|
76
|
+
qs.parse('a[b][c][d][e][f][g][h]=i'),
|
77
|
+
{ a: { b: { c: { d: { e: { f: { '[g][h]': 'i' } } } } } } },
|
78
|
+
'defaults to a depth of 5'
|
79
|
+
);
|
80
|
+
|
81
|
+
t.test('only parses one level when depth = 1', function (st) {
|
82
|
+
st.deepEqual(qs.parse('a[b][c]=d', { depth: 1 }), { a: { b: { '[c]': 'd' } } });
|
83
|
+
st.deepEqual(qs.parse('a[b][c][d]=e', { depth: 1 }), { a: { b: { '[c][d]': 'e' } } });
|
84
|
+
st.end();
|
85
|
+
});
|
86
|
+
|
87
|
+
t.test('uses original key when depth = 0', function (st) {
|
88
|
+
st.deepEqual(qs.parse('a[0]=b&a[1]=c', { depth: 0 }), { 'a[0]': 'b', 'a[1]': 'c' });
|
89
|
+
st.deepEqual(qs.parse('a[0][0]=b&a[0][1]=c&a[1]=d&e=2', { depth: 0 }), { 'a[0][0]': 'b', 'a[0][1]': 'c', 'a[1]': 'd', e: '2' });
|
90
|
+
st.end();
|
91
|
+
});
|
92
|
+
|
93
|
+
t.test('uses original key when depth = false', function (st) {
|
94
|
+
st.deepEqual(qs.parse('a[0]=b&a[1]=c', { depth: false }), { 'a[0]': 'b', 'a[1]': 'c' });
|
95
|
+
st.deepEqual(qs.parse('a[0][0]=b&a[0][1]=c&a[1]=d&e=2', { depth: false }), { 'a[0][0]': 'b', 'a[0][1]': 'c', 'a[1]': 'd', e: '2' });
|
96
|
+
st.end();
|
97
|
+
});
|
98
|
+
|
99
|
+
t.deepEqual(qs.parse('a=b&a=c'), { a: ['b', 'c'] }, 'parses a simple array');
|
100
|
+
|
101
|
+
t.test('parses an explicit array', function (st) {
|
102
|
+
st.deepEqual(qs.parse('a[]=b'), { a: ['b'] });
|
103
|
+
st.deepEqual(qs.parse('a[]=b&a[]=c'), { a: ['b', 'c'] });
|
104
|
+
st.deepEqual(qs.parse('a[]=b&a[]=c&a[]=d'), { a: ['b', 'c', 'd'] });
|
105
|
+
st.end();
|
106
|
+
});
|
107
|
+
|
108
|
+
t.test('parses a mix of simple and explicit arrays', function (st) {
|
109
|
+
st.deepEqual(qs.parse('a=b&a[]=c'), { a: ['b', 'c'] });
|
110
|
+
st.deepEqual(qs.parse('a[]=b&a=c'), { a: ['b', 'c'] });
|
111
|
+
st.deepEqual(qs.parse('a[0]=b&a=c'), { a: ['b', 'c'] });
|
112
|
+
st.deepEqual(qs.parse('a=b&a[0]=c'), { a: ['b', 'c'] });
|
113
|
+
|
114
|
+
st.deepEqual(qs.parse('a[1]=b&a=c', { arrayLimit: 20 }), { a: ['b', 'c'] });
|
115
|
+
st.deepEqual(qs.parse('a[]=b&a=c', { arrayLimit: 0 }), { a: ['b', 'c'] });
|
116
|
+
st.deepEqual(qs.parse('a[]=b&a=c'), { a: ['b', 'c'] });
|
117
|
+
|
118
|
+
st.deepEqual(qs.parse('a=b&a[1]=c', { arrayLimit: 20 }), { a: ['b', 'c'] });
|
119
|
+
st.deepEqual(qs.parse('a=b&a[]=c', { arrayLimit: 0 }), { a: ['b', 'c'] });
|
120
|
+
st.deepEqual(qs.parse('a=b&a[]=c'), { a: ['b', 'c'] });
|
121
|
+
|
122
|
+
st.end();
|
123
|
+
});
|
124
|
+
|
125
|
+
t.test('parses a nested array', function (st) {
|
126
|
+
st.deepEqual(qs.parse('a[b][]=c&a[b][]=d'), { a: { b: ['c', 'd'] } });
|
127
|
+
st.deepEqual(qs.parse('a[>=]=25'), { a: { '>=': '25' } });
|
128
|
+
st.end();
|
129
|
+
});
|
130
|
+
|
131
|
+
t.test('allows to specify array indices', function (st) {
|
132
|
+
st.deepEqual(qs.parse('a[1]=c&a[0]=b&a[2]=d'), { a: ['b', 'c', 'd'] });
|
133
|
+
st.deepEqual(qs.parse('a[1]=c&a[0]=b'), { a: ['b', 'c'] });
|
134
|
+
st.deepEqual(qs.parse('a[1]=c', { arrayLimit: 20 }), { a: ['c'] });
|
135
|
+
st.deepEqual(qs.parse('a[1]=c', { arrayLimit: 0 }), { a: { 1: 'c' } });
|
136
|
+
st.deepEqual(qs.parse('a[1]=c'), { a: ['c'] });
|
137
|
+
st.end();
|
138
|
+
});
|
139
|
+
|
140
|
+
t.test('limits specific array indices to arrayLimit', function (st) {
|
141
|
+
st.deepEqual(qs.parse('a[20]=a', { arrayLimit: 20 }), { a: ['a'] });
|
142
|
+
st.deepEqual(qs.parse('a[21]=a', { arrayLimit: 20 }), { a: { 21: 'a' } });
|
143
|
+
st.end();
|
144
|
+
});
|
145
|
+
|
146
|
+
t.deepEqual(qs.parse('a[12b]=c'), { a: { '12b': 'c' } }, 'supports keys that begin with a number');
|
147
|
+
|
148
|
+
t.test('supports encoded = signs', function (st) {
|
149
|
+
st.deepEqual(qs.parse('he%3Dllo=th%3Dere'), { 'he=llo': 'th=ere' });
|
150
|
+
st.end();
|
151
|
+
});
|
152
|
+
|
153
|
+
t.test('is ok with url encoded strings', function (st) {
|
154
|
+
st.deepEqual(qs.parse('a[b%20c]=d'), { a: { 'b c': 'd' } });
|
155
|
+
st.deepEqual(qs.parse('a[b]=c%20d'), { a: { b: 'c d' } });
|
156
|
+
st.end();
|
157
|
+
});
|
158
|
+
|
159
|
+
t.test('allows brackets in the value', function (st) {
|
160
|
+
st.deepEqual(qs.parse('pets=["tobi"]'), { pets: '["tobi"]' });
|
161
|
+
st.deepEqual(qs.parse('operators=[">=", "<="]'), { operators: '[">=", "<="]' });
|
162
|
+
st.end();
|
163
|
+
});
|
164
|
+
|
165
|
+
t.test('allows empty values', function (st) {
|
166
|
+
st.deepEqual(qs.parse(''), {});
|
167
|
+
st.deepEqual(qs.parse(null), {});
|
168
|
+
st.deepEqual(qs.parse(undefined), {});
|
169
|
+
st.end();
|
170
|
+
});
|
171
|
+
|
172
|
+
t.test('transforms arrays to objects', function (st) {
|
173
|
+
st.deepEqual(qs.parse('foo[0]=bar&foo[bad]=baz'), { foo: { 0: 'bar', bad: 'baz' } });
|
174
|
+
st.deepEqual(qs.parse('foo[bad]=baz&foo[0]=bar'), { foo: { bad: 'baz', 0: 'bar' } });
|
175
|
+
st.deepEqual(qs.parse('foo[bad]=baz&foo[]=bar'), { foo: { bad: 'baz', 0: 'bar' } });
|
176
|
+
st.deepEqual(qs.parse('foo[]=bar&foo[bad]=baz'), { foo: { 0: 'bar', bad: 'baz' } });
|
177
|
+
st.deepEqual(qs.parse('foo[bad]=baz&foo[]=bar&foo[]=foo'), { foo: { bad: 'baz', 0: 'bar', 1: 'foo' } });
|
178
|
+
st.deepEqual(qs.parse('foo[0][a]=a&foo[0][b]=b&foo[1][a]=aa&foo[1][b]=bb'), { foo: [{ a: 'a', b: 'b' }, { a: 'aa', b: 'bb' }] });
|
179
|
+
|
180
|
+
st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c', { allowPrototypes: false }), { a: { 0: 'b', t: 'u' } });
|
181
|
+
st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c', { allowPrototypes: true }), { a: { 0: 'b', t: 'u', hasOwnProperty: 'c' } });
|
182
|
+
st.deepEqual(qs.parse('a[]=b&a[hasOwnProperty]=c&a[x]=y', { allowPrototypes: false }), { a: { 0: 'b', x: 'y' } });
|
183
|
+
st.deepEqual(qs.parse('a[]=b&a[hasOwnProperty]=c&a[x]=y', { allowPrototypes: true }), { a: { 0: 'b', hasOwnProperty: 'c', x: 'y' } });
|
184
|
+
st.end();
|
185
|
+
});
|
186
|
+
|
187
|
+
t.test('transforms arrays to objects (dot notation)', function (st) {
|
188
|
+
st.deepEqual(qs.parse('foo[0].baz=bar&fool.bad=baz', { allowDots: true }), { foo: [{ baz: 'bar' }], fool: { bad: 'baz' } });
|
189
|
+
st.deepEqual(qs.parse('foo[0].baz=bar&fool.bad.boo=baz', { allowDots: true }), { foo: [{ baz: 'bar' }], fool: { bad: { boo: 'baz' } } });
|
190
|
+
st.deepEqual(qs.parse('foo[0][0].baz=bar&fool.bad=baz', { allowDots: true }), { foo: [[{ baz: 'bar' }]], fool: { bad: 'baz' } });
|
191
|
+
st.deepEqual(qs.parse('foo[0].baz[0]=15&foo[0].bar=2', { allowDots: true }), { foo: [{ baz: ['15'], bar: '2' }] });
|
192
|
+
st.deepEqual(qs.parse('foo[0].baz[0]=15&foo[0].baz[1]=16&foo[0].bar=2', { allowDots: true }), { foo: [{ baz: ['15', '16'], bar: '2' }] });
|
193
|
+
st.deepEqual(qs.parse('foo.bad=baz&foo[0]=bar', { allowDots: true }), { foo: { bad: 'baz', 0: 'bar' } });
|
194
|
+
st.deepEqual(qs.parse('foo.bad=baz&foo[]=bar', { allowDots: true }), { foo: { bad: 'baz', 0: 'bar' } });
|
195
|
+
st.deepEqual(qs.parse('foo[]=bar&foo.bad=baz', { allowDots: true }), { foo: { 0: 'bar', bad: 'baz' } });
|
196
|
+
st.deepEqual(qs.parse('foo.bad=baz&foo[]=bar&foo[]=foo', { allowDots: true }), { foo: { bad: 'baz', 0: 'bar', 1: 'foo' } });
|
197
|
+
st.deepEqual(qs.parse('foo[0].a=a&foo[0].b=b&foo[1].a=aa&foo[1].b=bb', { allowDots: true }), { foo: [{ a: 'a', b: 'b' }, { a: 'aa', b: 'bb' }] });
|
198
|
+
st.end();
|
199
|
+
});
|
200
|
+
|
201
|
+
t.test('correctly prunes undefined values when converting an array to an object', function (st) {
|
202
|
+
st.deepEqual(qs.parse('a[2]=b&a[99999999]=c'), { a: { 2: 'b', 99999999: 'c' } });
|
203
|
+
st.end();
|
204
|
+
});
|
205
|
+
|
206
|
+
t.test('supports malformed uri characters', function (st) {
|
207
|
+
st.deepEqual(qs.parse('{%:%}', { strictNullHandling: true }), { '{%:%}': null });
|
208
|
+
st.deepEqual(qs.parse('{%:%}='), { '{%:%}': '' });
|
209
|
+
st.deepEqual(qs.parse('foo=%:%}'), { foo: '%:%}' });
|
210
|
+
st.end();
|
211
|
+
});
|
212
|
+
|
213
|
+
t.test('doesn\'t produce empty keys', function (st) {
|
214
|
+
st.deepEqual(qs.parse('_r=1&'), { _r: '1' });
|
215
|
+
st.end();
|
216
|
+
});
|
217
|
+
|
218
|
+
t.test('cannot access Object prototype', function (st) {
|
219
|
+
qs.parse('constructor[prototype][bad]=bad');
|
220
|
+
qs.parse('bad[constructor][prototype][bad]=bad');
|
221
|
+
st.equal(typeof Object.prototype.bad, 'undefined');
|
222
|
+
st.end();
|
223
|
+
});
|
224
|
+
|
225
|
+
t.test('parses arrays of objects', function (st) {
|
226
|
+
st.deepEqual(qs.parse('a[][b]=c'), { a: [{ b: 'c' }] });
|
227
|
+
st.deepEqual(qs.parse('a[0][b]=c'), { a: [{ b: 'c' }] });
|
228
|
+
st.end();
|
229
|
+
});
|
230
|
+
|
231
|
+
t.test('allows for empty strings in arrays', function (st) {
|
232
|
+
st.deepEqual(qs.parse('a[]=b&a[]=&a[]=c'), { a: ['b', '', 'c'] });
|
233
|
+
|
234
|
+
st.deepEqual(
|
235
|
+
qs.parse('a[0]=b&a[1]&a[2]=c&a[19]=', { strictNullHandling: true, arrayLimit: 20 }),
|
236
|
+
{ a: ['b', null, 'c', ''] },
|
237
|
+
'with arrayLimit 20 + array indices: null then empty string works'
|
238
|
+
);
|
239
|
+
st.deepEqual(
|
240
|
+
qs.parse('a[]=b&a[]&a[]=c&a[]=', { strictNullHandling: true, arrayLimit: 0 }),
|
241
|
+
{ a: ['b', null, 'c', ''] },
|
242
|
+
'with arrayLimit 0 + array brackets: null then empty string works'
|
243
|
+
);
|
244
|
+
|
245
|
+
st.deepEqual(
|
246
|
+
qs.parse('a[0]=b&a[1]=&a[2]=c&a[19]', { strictNullHandling: true, arrayLimit: 20 }),
|
247
|
+
{ a: ['b', '', 'c', null] },
|
248
|
+
'with arrayLimit 20 + array indices: empty string then null works'
|
249
|
+
);
|
250
|
+
st.deepEqual(
|
251
|
+
qs.parse('a[]=b&a[]=&a[]=c&a[]', { strictNullHandling: true, arrayLimit: 0 }),
|
252
|
+
{ a: ['b', '', 'c', null] },
|
253
|
+
'with arrayLimit 0 + array brackets: empty string then null works'
|
254
|
+
);
|
255
|
+
|
256
|
+
st.deepEqual(
|
257
|
+
qs.parse('a[]=&a[]=b&a[]=c'),
|
258
|
+
{ a: ['', 'b', 'c'] },
|
259
|
+
'array brackets: empty strings work'
|
260
|
+
);
|
261
|
+
st.end();
|
262
|
+
});
|
263
|
+
|
264
|
+
t.test('compacts sparse arrays', function (st) {
|
265
|
+
st.deepEqual(qs.parse('a[10]=1&a[2]=2', { arrayLimit: 20 }), { a: ['2', '1'] });
|
266
|
+
st.deepEqual(qs.parse('a[1][b][2][c]=1', { arrayLimit: 20 }), { a: [{ b: [{ c: '1' }] }] });
|
267
|
+
st.deepEqual(qs.parse('a[1][2][3][c]=1', { arrayLimit: 20 }), { a: [[[{ c: '1' }]]] });
|
268
|
+
st.deepEqual(qs.parse('a[1][2][3][c][1]=1', { arrayLimit: 20 }), { a: [[[{ c: ['1'] }]]] });
|
269
|
+
st.end();
|
270
|
+
});
|
271
|
+
|
272
|
+
t.test('parses semi-parsed strings', function (st) {
|
273
|
+
st.deepEqual(qs.parse({ 'a[b]': 'c' }), { a: { b: 'c' } });
|
274
|
+
st.deepEqual(qs.parse({ 'a[b]': 'c', 'a[d]': 'e' }), { a: { b: 'c', d: 'e' } });
|
275
|
+
st.end();
|
276
|
+
});
|
277
|
+
|
278
|
+
t.test('parses buffers correctly', function (st) {
|
279
|
+
var b = SaferBuffer.from('test');
|
280
|
+
st.deepEqual(qs.parse({ a: b }), { a: b });
|
281
|
+
st.end();
|
282
|
+
});
|
283
|
+
|
284
|
+
t.test('parses jquery-param strings', function (st) {
|
285
|
+
// readable = 'filter[0][]=int1&filter[0][]==&filter[0][]=77&filter[]=and&filter[2][]=int2&filter[2][]==&filter[2][]=8'
|
286
|
+
var encoded = 'filter%5B0%5D%5B%5D=int1&filter%5B0%5D%5B%5D=%3D&filter%5B0%5D%5B%5D=77&filter%5B%5D=and&filter%5B2%5D%5B%5D=int2&filter%5B2%5D%5B%5D=%3D&filter%5B2%5D%5B%5D=8';
|
287
|
+
var expected = { filter: [['int1', '=', '77'], 'and', ['int2', '=', '8']] };
|
288
|
+
st.deepEqual(qs.parse(encoded), expected);
|
289
|
+
st.end();
|
290
|
+
});
|
291
|
+
|
292
|
+
t.test('continues parsing when no parent is found', function (st) {
|
293
|
+
st.deepEqual(qs.parse('[]=&a=b'), { 0: '', a: 'b' });
|
294
|
+
st.deepEqual(qs.parse('[]&a=b', { strictNullHandling: true }), { 0: null, a: 'b' });
|
295
|
+
st.deepEqual(qs.parse('[foo]=bar'), { foo: 'bar' });
|
296
|
+
st.end();
|
297
|
+
});
|
298
|
+
|
299
|
+
t.test('does not error when parsing a very long array', function (st) {
|
300
|
+
var str = 'a[]=a';
|
301
|
+
while (Buffer.byteLength(str) < 128 * 1024) {
|
302
|
+
str = str + '&' + str;
|
303
|
+
}
|
304
|
+
|
305
|
+
st.doesNotThrow(function () {
|
306
|
+
qs.parse(str);
|
307
|
+
});
|
308
|
+
|
309
|
+
st.end();
|
310
|
+
});
|
311
|
+
|
312
|
+
t.test('should not throw when a native prototype has an enumerable property', function (st) {
|
313
|
+
Object.prototype.crash = '';
|
314
|
+
Array.prototype.crash = '';
|
315
|
+
st.doesNotThrow(qs.parse.bind(null, 'a=b'));
|
316
|
+
st.deepEqual(qs.parse('a=b'), { a: 'b' });
|
317
|
+
st.doesNotThrow(qs.parse.bind(null, 'a[][b]=c'));
|
318
|
+
st.deepEqual(qs.parse('a[][b]=c'), { a: [{ b: 'c' }] });
|
319
|
+
delete Object.prototype.crash;
|
320
|
+
delete Array.prototype.crash;
|
321
|
+
st.end();
|
322
|
+
});
|
323
|
+
|
324
|
+
t.test('parses a string with an alternative string delimiter', function (st) {
|
325
|
+
st.deepEqual(qs.parse('a=b;c=d', { delimiter: ';' }), { a: 'b', c: 'd' });
|
326
|
+
st.end();
|
327
|
+
});
|
328
|
+
|
329
|
+
t.test('parses a string with an alternative RegExp delimiter', function (st) {
|
330
|
+
st.deepEqual(qs.parse('a=b; c=d', { delimiter: /[;,] */ }), { a: 'b', c: 'd' });
|
331
|
+
st.end();
|
332
|
+
});
|
333
|
+
|
334
|
+
t.test('does not use non-splittable objects as delimiters', function (st) {
|
335
|
+
st.deepEqual(qs.parse('a=b&c=d', { delimiter: true }), { a: 'b', c: 'd' });
|
336
|
+
st.end();
|
337
|
+
});
|
338
|
+
|
339
|
+
t.test('allows overriding parameter limit', function (st) {
|
340
|
+
st.deepEqual(qs.parse('a=b&c=d', { parameterLimit: 1 }), { a: 'b' });
|
341
|
+
st.end();
|
342
|
+
});
|
343
|
+
|
344
|
+
t.test('allows setting the parameter limit to Infinity', function (st) {
|
345
|
+
st.deepEqual(qs.parse('a=b&c=d', { parameterLimit: Infinity }), { a: 'b', c: 'd' });
|
346
|
+
st.end();
|
347
|
+
});
|
348
|
+
|
349
|
+
t.test('allows overriding array limit', function (st) {
|
350
|
+
st.deepEqual(qs.parse('a[0]=b', { arrayLimit: -1 }), { a: { 0: 'b' } });
|
351
|
+
st.deepEqual(qs.parse('a[-1]=b', { arrayLimit: -1 }), { a: { '-1': 'b' } });
|
352
|
+
st.deepEqual(qs.parse('a[0]=b&a[1]=c', { arrayLimit: 0 }), { a: { 0: 'b', 1: 'c' } });
|
353
|
+
st.end();
|
354
|
+
});
|
355
|
+
|
356
|
+
t.test('allows disabling array parsing', function (st) {
|
357
|
+
var indices = qs.parse('a[0]=b&a[1]=c', { parseArrays: false });
|
358
|
+
st.deepEqual(indices, { a: { 0: 'b', 1: 'c' } });
|
359
|
+
st.equal(Array.isArray(indices.a), false, 'parseArrays:false, indices case is not an array');
|
360
|
+
|
361
|
+
var emptyBrackets = qs.parse('a[]=b', { parseArrays: false });
|
362
|
+
st.deepEqual(emptyBrackets, { a: { 0: 'b' } });
|
363
|
+
st.equal(Array.isArray(emptyBrackets.a), false, 'parseArrays:false, empty brackets case is not an array');
|
364
|
+
|
365
|
+
st.end();
|
366
|
+
});
|
367
|
+
|
368
|
+
t.test('allows for query string prefix', function (st) {
|
369
|
+
st.deepEqual(qs.parse('?foo=bar', { ignoreQueryPrefix: true }), { foo: 'bar' });
|
370
|
+
st.deepEqual(qs.parse('foo=bar', { ignoreQueryPrefix: true }), { foo: 'bar' });
|
371
|
+
st.deepEqual(qs.parse('?foo=bar', { ignoreQueryPrefix: false }), { '?foo': 'bar' });
|
372
|
+
st.end();
|
373
|
+
});
|
374
|
+
|
375
|
+
t.test('parses an object', function (st) {
|
376
|
+
var input = {
|
377
|
+
'user[name]': { 'pop[bob]': 3 },
|
378
|
+
'user[email]': null
|
379
|
+
};
|
380
|
+
|
381
|
+
var expected = {
|
382
|
+
user: {
|
383
|
+
name: { 'pop[bob]': 3 },
|
384
|
+
email: null
|
385
|
+
}
|
386
|
+
};
|
387
|
+
|
388
|
+
var result = qs.parse(input);
|
389
|
+
|
390
|
+
st.deepEqual(result, expected);
|
391
|
+
st.end();
|
392
|
+
});
|
393
|
+
|
394
|
+
t.test('parses string with comma as array divider', function (st) {
|
395
|
+
st.deepEqual(qs.parse('foo=bar,tee', { comma: true }), { foo: ['bar', 'tee'] });
|
396
|
+
st.deepEqual(qs.parse('foo[bar]=coffee,tee', { comma: true }), { foo: { bar: ['coffee', 'tee'] } });
|
397
|
+
st.deepEqual(qs.parse('foo=', { comma: true }), { foo: '' });
|
398
|
+
st.deepEqual(qs.parse('foo', { comma: true }), { foo: '' });
|
399
|
+
st.deepEqual(qs.parse('foo', { comma: true, strictNullHandling: true }), { foo: null });
|
400
|
+
st.end();
|
401
|
+
});
|
402
|
+
|
403
|
+
t.test('parses values with comma as array divider', function (st) {
|
404
|
+
st.deepEqual(qs.parse({ foo: 'bar,tee' }, { comma: false }), { foo: 'bar,tee' });
|
405
|
+
st.deepEqual(qs.parse({ foo: 'bar,tee' }, { comma: true }), { foo: ['bar', 'tee'] });
|
406
|
+
st.end();
|
407
|
+
});
|
408
|
+
|
409
|
+
t.test('use number decoder, parses string that has one number with comma option enabled', function (st) {
|
410
|
+
var decoder = function (str, defaultDecoder, charset, type) {
|
411
|
+
if (!isNaN(Number(str))) {
|
412
|
+
return parseFloat(str);
|
413
|
+
}
|
414
|
+
return defaultDecoder(str, defaultDecoder, charset, type);
|
415
|
+
};
|
416
|
+
|
417
|
+
st.deepEqual(qs.parse('foo=1', { comma: true, decoder: decoder }), { foo: 1 });
|
418
|
+
st.deepEqual(qs.parse('foo=0', { comma: true, decoder: decoder }), { foo: 0 });
|
419
|
+
|
420
|
+
st.end();
|
421
|
+
});
|
422
|
+
|
423
|
+
t.test('parses brackets holds array of arrays when having two parts of strings with comma as array divider', function (st) {
|
424
|
+
st.deepEqual(qs.parse('foo[]=1,2,3&foo[]=4,5,6', { comma: true }), { foo: [['1', '2', '3'], ['4', '5', '6']] });
|
425
|
+
st.deepEqual(qs.parse('foo[]=1,2,3&foo[]=', { comma: true }), { foo: [['1', '2', '3'], ''] });
|
426
|
+
st.deepEqual(qs.parse('foo[]=1,2,3&foo[]=,', { comma: true }), { foo: [['1', '2', '3'], ['', '']] });
|
427
|
+
st.deepEqual(qs.parse('foo[]=1,2,3&foo[]=a', { comma: true }), { foo: [['1', '2', '3'], 'a'] });
|
428
|
+
|
429
|
+
st.end();
|
430
|
+
});
|
431
|
+
|
432
|
+
t.test('parses comma delimited array while having percent-encoded comma treated as normal text', function (st) {
|
433
|
+
st.deepEqual(qs.parse('foo=a%2Cb', { comma: true }), { foo: 'a,b' });
|
434
|
+
st.deepEqual(qs.parse('foo=a%2C%20b,d', { comma: true }), { foo: ['a, b', 'd'] });
|
435
|
+
st.deepEqual(qs.parse('foo=a%2C%20b,c%2C%20d', { comma: true }), { foo: ['a, b', 'c, d'] });
|
436
|
+
|
437
|
+
st.end();
|
438
|
+
});
|
439
|
+
|
440
|
+
t.test('parses an object in dot notation', function (st) {
|
441
|
+
var input = {
|
442
|
+
'user.name': { 'pop[bob]': 3 },
|
443
|
+
'user.email.': null
|
444
|
+
};
|
445
|
+
|
446
|
+
var expected = {
|
447
|
+
user: {
|
448
|
+
name: { 'pop[bob]': 3 },
|
449
|
+
email: null
|
450
|
+
}
|
451
|
+
};
|
452
|
+
|
453
|
+
var result = qs.parse(input, { allowDots: true });
|
454
|
+
|
455
|
+
st.deepEqual(result, expected);
|
456
|
+
st.end();
|
457
|
+
});
|
458
|
+
|
459
|
+
t.test('parses an object and not child values', function (st) {
|
460
|
+
var input = {
|
461
|
+
'user[name]': { 'pop[bob]': { test: 3 } },
|
462
|
+
'user[email]': null
|
463
|
+
};
|
464
|
+
|
465
|
+
var expected = {
|
466
|
+
user: {
|
467
|
+
name: { 'pop[bob]': { test: 3 } },
|
468
|
+
email: null
|
469
|
+
}
|
470
|
+
};
|
471
|
+
|
472
|
+
var result = qs.parse(input);
|
473
|
+
|
474
|
+
st.deepEqual(result, expected);
|
475
|
+
st.end();
|
476
|
+
});
|
477
|
+
|
478
|
+
t.test('does not blow up when Buffer global is missing', function (st) {
|
479
|
+
var tempBuffer = global.Buffer;
|
480
|
+
delete global.Buffer;
|
481
|
+
var result = qs.parse('a=b&c=d');
|
482
|
+
global.Buffer = tempBuffer;
|
483
|
+
st.deepEqual(result, { a: 'b', c: 'd' });
|
484
|
+
st.end();
|
485
|
+
});
|
486
|
+
|
487
|
+
t.test('does not crash when parsing circular references', function (st) {
|
488
|
+
var a = {};
|
489
|
+
a.b = a;
|
490
|
+
|
491
|
+
var parsed;
|
492
|
+
|
493
|
+
st.doesNotThrow(function () {
|
494
|
+
parsed = qs.parse({ 'foo[bar]': 'baz', 'foo[baz]': a });
|
495
|
+
});
|
496
|
+
|
497
|
+
st.equal('foo' in parsed, true, 'parsed has "foo" property');
|
498
|
+
st.equal('bar' in parsed.foo, true);
|
499
|
+
st.equal('baz' in parsed.foo, true);
|
500
|
+
st.equal(parsed.foo.bar, 'baz');
|
501
|
+
st.deepEqual(parsed.foo.baz, a);
|
502
|
+
st.end();
|
503
|
+
});
|
504
|
+
|
505
|
+
t.test('does not crash when parsing deep objects', function (st) {
|
506
|
+
var parsed;
|
507
|
+
var str = 'foo';
|
508
|
+
|
509
|
+
for (var i = 0; i < 5000; i++) {
|
510
|
+
str += '[p]';
|
511
|
+
}
|
512
|
+
|
513
|
+
str += '=bar';
|
514
|
+
|
515
|
+
st.doesNotThrow(function () {
|
516
|
+
parsed = qs.parse(str, { depth: 5000 });
|
517
|
+
});
|
518
|
+
|
519
|
+
st.equal('foo' in parsed, true, 'parsed has "foo" property');
|
520
|
+
|
521
|
+
var depth = 0;
|
522
|
+
var ref = parsed.foo;
|
523
|
+
while ((ref = ref.p)) {
|
524
|
+
depth += 1;
|
525
|
+
}
|
526
|
+
|
527
|
+
st.equal(depth, 5000, 'parsed is 5000 properties deep');
|
528
|
+
|
529
|
+
st.end();
|
530
|
+
});
|
531
|
+
|
532
|
+
t.test('parses null objects correctly', { skip: !Object.create }, function (st) {
|
533
|
+
var a = Object.create(null);
|
534
|
+
a.b = 'c';
|
535
|
+
|
536
|
+
st.deepEqual(qs.parse(a), { b: 'c' });
|
537
|
+
var result = qs.parse({ a: a });
|
538
|
+
st.equal('a' in result, true, 'result has "a" property');
|
539
|
+
st.deepEqual(result.a, a);
|
540
|
+
st.end();
|
541
|
+
});
|
542
|
+
|
543
|
+
t.test('parses dates correctly', function (st) {
|
544
|
+
var now = new Date();
|
545
|
+
st.deepEqual(qs.parse({ a: now }), { a: now });
|
546
|
+
st.end();
|
547
|
+
});
|
548
|
+
|
549
|
+
t.test('parses regular expressions correctly', function (st) {
|
550
|
+
var re = /^test$/;
|
551
|
+
st.deepEqual(qs.parse({ a: re }), { a: re });
|
552
|
+
st.end();
|
553
|
+
});
|
554
|
+
|
555
|
+
t.test('does not allow overwriting prototype properties', function (st) {
|
556
|
+
st.deepEqual(qs.parse('a[hasOwnProperty]=b', { allowPrototypes: false }), {});
|
557
|
+
st.deepEqual(qs.parse('hasOwnProperty=b', { allowPrototypes: false }), {});
|
558
|
+
|
559
|
+
st.deepEqual(
|
560
|
+
qs.parse('toString', { allowPrototypes: false }),
|
561
|
+
{},
|
562
|
+
'bare "toString" results in {}'
|
563
|
+
);
|
564
|
+
|
565
|
+
st.end();
|
566
|
+
});
|
567
|
+
|
568
|
+
t.test('can allow overwriting prototype properties', function (st) {
|
569
|
+
st.deepEqual(qs.parse('a[hasOwnProperty]=b', { allowPrototypes: true }), { a: { hasOwnProperty: 'b' } });
|
570
|
+
st.deepEqual(qs.parse('hasOwnProperty=b', { allowPrototypes: true }), { hasOwnProperty: 'b' });
|
571
|
+
|
572
|
+
st.deepEqual(
|
573
|
+
qs.parse('toString', { allowPrototypes: true }),
|
574
|
+
{ toString: '' },
|
575
|
+
'bare "toString" results in { toString: "" }'
|
576
|
+
);
|
577
|
+
|
578
|
+
st.end();
|
579
|
+
});
|
580
|
+
|
581
|
+
t.test('params starting with a closing bracket', function (st) {
|
582
|
+
st.deepEqual(qs.parse(']=toString'), { ']': 'toString' });
|
583
|
+
st.deepEqual(qs.parse(']]=toString'), { ']]': 'toString' });
|
584
|
+
st.deepEqual(qs.parse(']hello]=toString'), { ']hello]': 'toString' });
|
585
|
+
st.end();
|
586
|
+
});
|
587
|
+
|
588
|
+
t.test('params starting with a starting bracket', function (st) {
|
589
|
+
st.deepEqual(qs.parse('[=toString'), { '[': 'toString' });
|
590
|
+
st.deepEqual(qs.parse('[[=toString'), { '[[': 'toString' });
|
591
|
+
st.deepEqual(qs.parse('[hello[=toString'), { '[hello[': 'toString' });
|
592
|
+
st.end();
|
593
|
+
});
|
594
|
+
|
595
|
+
t.test('add keys to objects', function (st) {
|
596
|
+
st.deepEqual(
|
597
|
+
qs.parse('a[b]=c&a=d'),
|
598
|
+
{ a: { b: 'c', d: true } },
|
599
|
+
'can add keys to objects'
|
600
|
+
);
|
601
|
+
|
602
|
+
st.deepEqual(
|
603
|
+
qs.parse('a[b]=c&a=toString'),
|
604
|
+
{ a: { b: 'c' } },
|
605
|
+
'can not overwrite prototype'
|
606
|
+
);
|
607
|
+
|
608
|
+
st.deepEqual(
|
609
|
+
qs.parse('a[b]=c&a=toString', { allowPrototypes: true }),
|
610
|
+
{ a: { b: 'c', toString: true } },
|
611
|
+
'can overwrite prototype with allowPrototypes true'
|
612
|
+
);
|
613
|
+
|
614
|
+
st.deepEqual(
|
615
|
+
qs.parse('a[b]=c&a=toString', { plainObjects: true }),
|
616
|
+
{ __proto__: null, a: { __proto__: null, b: 'c', toString: true } },
|
617
|
+
'can overwrite prototype with plainObjects true'
|
618
|
+
);
|
619
|
+
|
620
|
+
st.end();
|
621
|
+
});
|
622
|
+
|
623
|
+
t.test('can return null objects', { skip: !Object.create }, function (st) {
|
624
|
+
var expected = Object.create(null);
|
625
|
+
expected.a = Object.create(null);
|
626
|
+
expected.a.b = 'c';
|
627
|
+
expected.a.hasOwnProperty = 'd';
|
628
|
+
st.deepEqual(qs.parse('a[b]=c&a[hasOwnProperty]=d', { plainObjects: true }), expected);
|
629
|
+
st.deepEqual(qs.parse(null, { plainObjects: true }), Object.create(null));
|
630
|
+
var expectedArray = Object.create(null);
|
631
|
+
expectedArray.a = Object.create(null);
|
632
|
+
expectedArray.a[0] = 'b';
|
633
|
+
expectedArray.a.c = 'd';
|
634
|
+
st.deepEqual(qs.parse('a[]=b&a[c]=d', { plainObjects: true }), expectedArray);
|
635
|
+
st.end();
|
636
|
+
});
|
637
|
+
|
638
|
+
t.test('can parse with custom encoding', function (st) {
|
639
|
+
st.deepEqual(qs.parse('%8c%a7=%91%e5%8d%e3%95%7b', {
|
640
|
+
decoder: function (str) {
|
641
|
+
var reg = /%([0-9A-F]{2})/ig;
|
642
|
+
var result = [];
|
643
|
+
var parts = reg.exec(str);
|
644
|
+
while (parts) {
|
645
|
+
result.push(parseInt(parts[1], 16));
|
646
|
+
parts = reg.exec(str);
|
647
|
+
}
|
648
|
+
return String(iconv.decode(SaferBuffer.from(result), 'shift_jis'));
|
649
|
+
}
|
650
|
+
}), { 県: '大阪府' });
|
651
|
+
st.end();
|
652
|
+
});
|
653
|
+
|
654
|
+
t.test('receives the default decoder as a second argument', function (st) {
|
655
|
+
st.plan(1);
|
656
|
+
qs.parse('a', {
|
657
|
+
decoder: function (str, defaultDecoder) {
|
658
|
+
st.equal(defaultDecoder, utils.decode);
|
659
|
+
}
|
660
|
+
});
|
661
|
+
st.end();
|
662
|
+
});
|
663
|
+
|
664
|
+
t.test('throws error with wrong decoder', function (st) {
|
665
|
+
st['throws'](function () {
|
666
|
+
qs.parse({}, { decoder: 'string' });
|
667
|
+
}, new TypeError('Decoder has to be a function.'));
|
668
|
+
st.end();
|
669
|
+
});
|
670
|
+
|
671
|
+
t.test('does not mutate the options argument', function (st) {
|
672
|
+
var options = {};
|
673
|
+
qs.parse('a[b]=true', options);
|
674
|
+
st.deepEqual(options, {});
|
675
|
+
st.end();
|
676
|
+
});
|
677
|
+
|
678
|
+
t.test('throws if an invalid charset is specified', function (st) {
|
679
|
+
st['throws'](function () {
|
680
|
+
qs.parse('a=b', { charset: 'foobar' });
|
681
|
+
}, new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined'));
|
682
|
+
st.end();
|
683
|
+
});
|
684
|
+
|
685
|
+
t.test('parses an iso-8859-1 string if asked to', function (st) {
|
686
|
+
st.deepEqual(qs.parse('%A2=%BD', { charset: 'iso-8859-1' }), { '¢': '½' });
|
687
|
+
st.end();
|
688
|
+
});
|
689
|
+
|
690
|
+
var urlEncodedCheckmarkInUtf8 = '%E2%9C%93';
|
691
|
+
var urlEncodedOSlashInUtf8 = '%C3%B8';
|
692
|
+
var urlEncodedNumCheckmark = '%26%2310003%3B';
|
693
|
+
var urlEncodedNumSmiley = '%26%239786%3B';
|
694
|
+
|
695
|
+
t.test('prefers an utf-8 charset specified by the utf8 sentinel to a default charset of iso-8859-1', function (st) {
|
696
|
+
st.deepEqual(qs.parse('utf8=' + urlEncodedCheckmarkInUtf8 + '&' + urlEncodedOSlashInUtf8 + '=' + urlEncodedOSlashInUtf8, { charsetSentinel: true, charset: 'iso-8859-1' }), { ø: 'ø' });
|
697
|
+
st.end();
|
698
|
+
});
|
699
|
+
|
700
|
+
t.test('prefers an iso-8859-1 charset specified by the utf8 sentinel to a default charset of utf-8', function (st) {
|
701
|
+
st.deepEqual(qs.parse('utf8=' + urlEncodedNumCheckmark + '&' + urlEncodedOSlashInUtf8 + '=' + urlEncodedOSlashInUtf8, { charsetSentinel: true, charset: 'utf-8' }), { 'ø': 'ø' });
|
702
|
+
st.end();
|
703
|
+
});
|
704
|
+
|
705
|
+
t.test('does not require the utf8 sentinel to be defined before the parameters whose decoding it affects', function (st) {
|
706
|
+
st.deepEqual(qs.parse('a=' + urlEncodedOSlashInUtf8 + '&utf8=' + urlEncodedNumCheckmark, { charsetSentinel: true, charset: 'utf-8' }), { a: 'ø' });
|
707
|
+
st.end();
|
708
|
+
});
|
709
|
+
|
710
|
+
t.test('should ignore an utf8 sentinel with an unknown value', function (st) {
|
711
|
+
st.deepEqual(qs.parse('utf8=foo&' + urlEncodedOSlashInUtf8 + '=' + urlEncodedOSlashInUtf8, { charsetSentinel: true, charset: 'utf-8' }), { ø: 'ø' });
|
712
|
+
st.end();
|
713
|
+
});
|
714
|
+
|
715
|
+
t.test('uses the utf8 sentinel to switch to utf-8 when no default charset is given', function (st) {
|
716
|
+
st.deepEqual(qs.parse('utf8=' + urlEncodedCheckmarkInUtf8 + '&' + urlEncodedOSlashInUtf8 + '=' + urlEncodedOSlashInUtf8, { charsetSentinel: true }), { ø: 'ø' });
|
717
|
+
st.end();
|
718
|
+
});
|
719
|
+
|
720
|
+
t.test('uses the utf8 sentinel to switch to iso-8859-1 when no default charset is given', function (st) {
|
721
|
+
st.deepEqual(qs.parse('utf8=' + urlEncodedNumCheckmark + '&' + urlEncodedOSlashInUtf8 + '=' + urlEncodedOSlashInUtf8, { charsetSentinel: true }), { 'ø': 'ø' });
|
722
|
+
st.end();
|
723
|
+
});
|
724
|
+
|
725
|
+
t.test('interprets numeric entities in iso-8859-1 when `interpretNumericEntities`', function (st) {
|
726
|
+
st.deepEqual(qs.parse('foo=' + urlEncodedNumSmiley, { charset: 'iso-8859-1', interpretNumericEntities: true }), { foo: '☺' });
|
727
|
+
st.end();
|
728
|
+
});
|
729
|
+
|
730
|
+
t.test('handles a custom decoder returning `null`, in the `iso-8859-1` charset, when `interpretNumericEntities`', function (st) {
|
731
|
+
st.deepEqual(qs.parse('foo=&bar=' + urlEncodedNumSmiley, {
|
732
|
+
charset: 'iso-8859-1',
|
733
|
+
decoder: function (str, defaultDecoder, charset) {
|
734
|
+
return str ? defaultDecoder(str, defaultDecoder, charset) : null;
|
735
|
+
},
|
736
|
+
interpretNumericEntities: true
|
737
|
+
}), { foo: null, bar: '☺' });
|
738
|
+
st.end();
|
739
|
+
});
|
740
|
+
|
741
|
+
t.test('does not interpret numeric entities in iso-8859-1 when `interpretNumericEntities` is absent', function (st) {
|
742
|
+
st.deepEqual(qs.parse('foo=' + urlEncodedNumSmiley, { charset: 'iso-8859-1' }), { foo: '☺' });
|
743
|
+
st.end();
|
744
|
+
});
|
745
|
+
|
746
|
+
t.test('does not interpret numeric entities when the charset is utf-8, even when `interpretNumericEntities`', function (st) {
|
747
|
+
st.deepEqual(qs.parse('foo=' + urlEncodedNumSmiley, { charset: 'utf-8', interpretNumericEntities: true }), { foo: '☺' });
|
748
|
+
st.end();
|
749
|
+
});
|
750
|
+
|
751
|
+
t.test('does not interpret %uXXXX syntax in iso-8859-1 mode', function (st) {
|
752
|
+
st.deepEqual(qs.parse('%u263A=%u263A', { charset: 'iso-8859-1' }), { '%u263A': '%u263A' });
|
753
|
+
st.end();
|
754
|
+
});
|
755
|
+
|
756
|
+
t.test('allows for decoding keys and values differently', function (st) {
|
757
|
+
var decoder = function (str, defaultDecoder, charset, type) {
|
758
|
+
if (type === 'key') {
|
759
|
+
return defaultDecoder(str, defaultDecoder, charset, type).toLowerCase();
|
760
|
+
}
|
761
|
+
if (type === 'value') {
|
762
|
+
return defaultDecoder(str, defaultDecoder, charset, type).toUpperCase();
|
763
|
+
}
|
764
|
+
throw 'this should never happen! type: ' + type;
|
765
|
+
};
|
766
|
+
|
767
|
+
st.deepEqual(qs.parse('KeY=vAlUe', { decoder: decoder }), { key: 'VALUE' });
|
768
|
+
st.end();
|
769
|
+
});
|
770
|
+
|
771
|
+
t.end();
|
772
|
+
});
|