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,284 @@
|
|
1
|
+
/*!
|
2
|
+
* body-parser
|
3
|
+
* Copyright(c) 2014 Jonathan Ong
|
4
|
+
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
5
|
+
* MIT Licensed
|
6
|
+
*/
|
7
|
+
|
8
|
+
'use strict'
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Module dependencies.
|
12
|
+
* @private
|
13
|
+
*/
|
14
|
+
|
15
|
+
var bytes = require('bytes')
|
16
|
+
var contentType = require('content-type')
|
17
|
+
var createError = require('http-errors')
|
18
|
+
var debug = require('debug')('body-parser:urlencoded')
|
19
|
+
var deprecate = require('depd')('body-parser')
|
20
|
+
var read = require('../read')
|
21
|
+
var typeis = require('type-is')
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Module exports.
|
25
|
+
*/
|
26
|
+
|
27
|
+
module.exports = urlencoded
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Cache of parser modules.
|
31
|
+
*/
|
32
|
+
|
33
|
+
var parsers = Object.create(null)
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Create a middleware to parse urlencoded bodies.
|
37
|
+
*
|
38
|
+
* @param {object} [options]
|
39
|
+
* @return {function}
|
40
|
+
* @public
|
41
|
+
*/
|
42
|
+
|
43
|
+
function urlencoded (options) {
|
44
|
+
var opts = options || {}
|
45
|
+
|
46
|
+
// notice because option default will flip in next major
|
47
|
+
if (opts.extended === undefined) {
|
48
|
+
deprecate('undefined extended: provide extended option')
|
49
|
+
}
|
50
|
+
|
51
|
+
var extended = opts.extended !== false
|
52
|
+
var inflate = opts.inflate !== false
|
53
|
+
var limit = typeof opts.limit !== 'number'
|
54
|
+
? bytes.parse(opts.limit || '100kb')
|
55
|
+
: opts.limit
|
56
|
+
var type = opts.type || 'application/x-www-form-urlencoded'
|
57
|
+
var verify = opts.verify || false
|
58
|
+
|
59
|
+
if (verify !== false && typeof verify !== 'function') {
|
60
|
+
throw new TypeError('option verify must be function')
|
61
|
+
}
|
62
|
+
|
63
|
+
// create the appropriate query parser
|
64
|
+
var queryparse = extended
|
65
|
+
? extendedparser(opts)
|
66
|
+
: simpleparser(opts)
|
67
|
+
|
68
|
+
// create the appropriate type checking function
|
69
|
+
var shouldParse = typeof type !== 'function'
|
70
|
+
? typeChecker(type)
|
71
|
+
: type
|
72
|
+
|
73
|
+
function parse (body) {
|
74
|
+
return body.length
|
75
|
+
? queryparse(body)
|
76
|
+
: {}
|
77
|
+
}
|
78
|
+
|
79
|
+
return function urlencodedParser (req, res, next) {
|
80
|
+
if (req._body) {
|
81
|
+
debug('body already parsed')
|
82
|
+
next()
|
83
|
+
return
|
84
|
+
}
|
85
|
+
|
86
|
+
req.body = req.body || {}
|
87
|
+
|
88
|
+
// skip requests without bodies
|
89
|
+
if (!typeis.hasBody(req)) {
|
90
|
+
debug('skip empty body')
|
91
|
+
next()
|
92
|
+
return
|
93
|
+
}
|
94
|
+
|
95
|
+
debug('content-type %j', req.headers['content-type'])
|
96
|
+
|
97
|
+
// determine if request should be parsed
|
98
|
+
if (!shouldParse(req)) {
|
99
|
+
debug('skip parsing')
|
100
|
+
next()
|
101
|
+
return
|
102
|
+
}
|
103
|
+
|
104
|
+
// assert charset
|
105
|
+
var charset = getCharset(req) || 'utf-8'
|
106
|
+
if (charset !== 'utf-8') {
|
107
|
+
debug('invalid charset')
|
108
|
+
next(createError(415, 'unsupported charset "' + charset.toUpperCase() + '"', {
|
109
|
+
charset: charset,
|
110
|
+
type: 'charset.unsupported'
|
111
|
+
}))
|
112
|
+
return
|
113
|
+
}
|
114
|
+
|
115
|
+
// read
|
116
|
+
read(req, res, next, parse, debug, {
|
117
|
+
debug: debug,
|
118
|
+
encoding: charset,
|
119
|
+
inflate: inflate,
|
120
|
+
limit: limit,
|
121
|
+
verify: verify
|
122
|
+
})
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
/**
|
127
|
+
* Get the extended query parser.
|
128
|
+
*
|
129
|
+
* @param {object} options
|
130
|
+
*/
|
131
|
+
|
132
|
+
function extendedparser (options) {
|
133
|
+
var parameterLimit = options.parameterLimit !== undefined
|
134
|
+
? options.parameterLimit
|
135
|
+
: 1000
|
136
|
+
var parse = parser('qs')
|
137
|
+
|
138
|
+
if (isNaN(parameterLimit) || parameterLimit < 1) {
|
139
|
+
throw new TypeError('option parameterLimit must be a positive number')
|
140
|
+
}
|
141
|
+
|
142
|
+
if (isFinite(parameterLimit)) {
|
143
|
+
parameterLimit = parameterLimit | 0
|
144
|
+
}
|
145
|
+
|
146
|
+
return function queryparse (body) {
|
147
|
+
var paramCount = parameterCount(body, parameterLimit)
|
148
|
+
|
149
|
+
if (paramCount === undefined) {
|
150
|
+
debug('too many parameters')
|
151
|
+
throw createError(413, 'too many parameters', {
|
152
|
+
type: 'parameters.too.many'
|
153
|
+
})
|
154
|
+
}
|
155
|
+
|
156
|
+
var arrayLimit = Math.max(100, paramCount)
|
157
|
+
|
158
|
+
debug('parse extended urlencoding')
|
159
|
+
return parse(body, {
|
160
|
+
allowPrototypes: true,
|
161
|
+
arrayLimit: arrayLimit,
|
162
|
+
depth: Infinity,
|
163
|
+
parameterLimit: parameterLimit
|
164
|
+
})
|
165
|
+
}
|
166
|
+
}
|
167
|
+
|
168
|
+
/**
|
169
|
+
* Get the charset of a request.
|
170
|
+
*
|
171
|
+
* @param {object} req
|
172
|
+
* @api private
|
173
|
+
*/
|
174
|
+
|
175
|
+
function getCharset (req) {
|
176
|
+
try {
|
177
|
+
return (contentType.parse(req).parameters.charset || '').toLowerCase()
|
178
|
+
} catch (e) {
|
179
|
+
return undefined
|
180
|
+
}
|
181
|
+
}
|
182
|
+
|
183
|
+
/**
|
184
|
+
* Count the number of parameters, stopping once limit reached
|
185
|
+
*
|
186
|
+
* @param {string} body
|
187
|
+
* @param {number} limit
|
188
|
+
* @api private
|
189
|
+
*/
|
190
|
+
|
191
|
+
function parameterCount (body, limit) {
|
192
|
+
var count = 0
|
193
|
+
var index = 0
|
194
|
+
|
195
|
+
while ((index = body.indexOf('&', index)) !== -1) {
|
196
|
+
count++
|
197
|
+
index++
|
198
|
+
|
199
|
+
if (count === limit) {
|
200
|
+
return undefined
|
201
|
+
}
|
202
|
+
}
|
203
|
+
|
204
|
+
return count
|
205
|
+
}
|
206
|
+
|
207
|
+
/**
|
208
|
+
* Get parser for module name dynamically.
|
209
|
+
*
|
210
|
+
* @param {string} name
|
211
|
+
* @return {function}
|
212
|
+
* @api private
|
213
|
+
*/
|
214
|
+
|
215
|
+
function parser (name) {
|
216
|
+
var mod = parsers[name]
|
217
|
+
|
218
|
+
if (mod !== undefined) {
|
219
|
+
return mod.parse
|
220
|
+
}
|
221
|
+
|
222
|
+
// this uses a switch for static require analysis
|
223
|
+
switch (name) {
|
224
|
+
case 'qs':
|
225
|
+
mod = require('qs')
|
226
|
+
break
|
227
|
+
case 'querystring':
|
228
|
+
mod = require('querystring')
|
229
|
+
break
|
230
|
+
}
|
231
|
+
|
232
|
+
// store to prevent invoking require()
|
233
|
+
parsers[name] = mod
|
234
|
+
|
235
|
+
return mod.parse
|
236
|
+
}
|
237
|
+
|
238
|
+
/**
|
239
|
+
* Get the simple query parser.
|
240
|
+
*
|
241
|
+
* @param {object} options
|
242
|
+
*/
|
243
|
+
|
244
|
+
function simpleparser (options) {
|
245
|
+
var parameterLimit = options.parameterLimit !== undefined
|
246
|
+
? options.parameterLimit
|
247
|
+
: 1000
|
248
|
+
var parse = parser('querystring')
|
249
|
+
|
250
|
+
if (isNaN(parameterLimit) || parameterLimit < 1) {
|
251
|
+
throw new TypeError('option parameterLimit must be a positive number')
|
252
|
+
}
|
253
|
+
|
254
|
+
if (isFinite(parameterLimit)) {
|
255
|
+
parameterLimit = parameterLimit | 0
|
256
|
+
}
|
257
|
+
|
258
|
+
return function queryparse (body) {
|
259
|
+
var paramCount = parameterCount(body, parameterLimit)
|
260
|
+
|
261
|
+
if (paramCount === undefined) {
|
262
|
+
debug('too many parameters')
|
263
|
+
throw createError(413, 'too many parameters', {
|
264
|
+
type: 'parameters.too.many'
|
265
|
+
})
|
266
|
+
}
|
267
|
+
|
268
|
+
debug('parse urlencoding')
|
269
|
+
return parse(body, undefined, undefined, { maxKeys: parameterLimit })
|
270
|
+
}
|
271
|
+
}
|
272
|
+
|
273
|
+
/**
|
274
|
+
* Get the simple type checker.
|
275
|
+
*
|
276
|
+
* @param {string} type
|
277
|
+
* @return {function}
|
278
|
+
*/
|
279
|
+
|
280
|
+
function typeChecker (type) {
|
281
|
+
return function checkType (req) {
|
282
|
+
return Boolean(typeis(req, type))
|
283
|
+
}
|
284
|
+
}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
{
|
2
|
+
"name": "body-parser",
|
3
|
+
"description": "Node.js body parsing middleware",
|
4
|
+
"version": "1.19.1",
|
5
|
+
"contributors": [
|
6
|
+
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
7
|
+
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
|
8
|
+
],
|
9
|
+
"license": "MIT",
|
10
|
+
"repository": "expressjs/body-parser",
|
11
|
+
"dependencies": {
|
12
|
+
"bytes": "3.1.1",
|
13
|
+
"content-type": "~1.0.4",
|
14
|
+
"debug": "2.6.9",
|
15
|
+
"depd": "~1.1.2",
|
16
|
+
"http-errors": "1.8.1",
|
17
|
+
"iconv-lite": "0.4.24",
|
18
|
+
"on-finished": "~2.3.0",
|
19
|
+
"qs": "6.9.6",
|
20
|
+
"raw-body": "2.4.2",
|
21
|
+
"type-is": "~1.6.18"
|
22
|
+
},
|
23
|
+
"devDependencies": {
|
24
|
+
"eslint": "7.32.0",
|
25
|
+
"eslint-config-standard": "14.1.1",
|
26
|
+
"eslint-plugin-import": "2.25.3",
|
27
|
+
"eslint-plugin-markdown": "2.2.1",
|
28
|
+
"eslint-plugin-node": "11.1.0",
|
29
|
+
"eslint-plugin-promise": "5.2.0",
|
30
|
+
"eslint-plugin-standard": "4.1.0",
|
31
|
+
"methods": "1.1.2",
|
32
|
+
"mocha": "9.1.3",
|
33
|
+
"nyc": "15.1.0",
|
34
|
+
"safe-buffer": "5.2.1",
|
35
|
+
"supertest": "6.1.6"
|
36
|
+
},
|
37
|
+
"files": [
|
38
|
+
"lib/",
|
39
|
+
"LICENSE",
|
40
|
+
"HISTORY.md",
|
41
|
+
"index.js"
|
42
|
+
],
|
43
|
+
"engines": {
|
44
|
+
"node": ">= 0.8"
|
45
|
+
},
|
46
|
+
"scripts": {
|
47
|
+
"lint": "eslint .",
|
48
|
+
"test": "mocha --require test/support/env --reporter spec --check-leaks --bail test/",
|
49
|
+
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
50
|
+
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
51
|
+
}
|
52
|
+
}
|
@@ -0,0 +1,92 @@
|
|
1
|
+
3.1.1 / 2021-11-15
|
2
|
+
==================
|
3
|
+
|
4
|
+
* Fix "thousandsSeparator" incorrecting formatting fractional part
|
5
|
+
|
6
|
+
3.1.0 / 2019-01-22
|
7
|
+
==================
|
8
|
+
|
9
|
+
* Add petabyte (`pb`) support
|
10
|
+
|
11
|
+
3.0.0 / 2017-08-31
|
12
|
+
==================
|
13
|
+
|
14
|
+
* Change "kB" to "KB" in format output
|
15
|
+
* Remove support for Node.js 0.6
|
16
|
+
* Remove support for ComponentJS
|
17
|
+
|
18
|
+
2.5.0 / 2017-03-24
|
19
|
+
==================
|
20
|
+
|
21
|
+
* Add option "unit"
|
22
|
+
|
23
|
+
2.4.0 / 2016-06-01
|
24
|
+
==================
|
25
|
+
|
26
|
+
* Add option "unitSeparator"
|
27
|
+
|
28
|
+
2.3.0 / 2016-02-15
|
29
|
+
==================
|
30
|
+
|
31
|
+
* Drop partial bytes on all parsed units
|
32
|
+
* Fix non-finite numbers to `.format` to return `null`
|
33
|
+
* Fix parsing byte string that looks like hex
|
34
|
+
* perf: hoist regular expressions
|
35
|
+
|
36
|
+
2.2.0 / 2015-11-13
|
37
|
+
==================
|
38
|
+
|
39
|
+
* add option "decimalPlaces"
|
40
|
+
* add option "fixedDecimals"
|
41
|
+
|
42
|
+
2.1.0 / 2015-05-21
|
43
|
+
==================
|
44
|
+
|
45
|
+
* add `.format` export
|
46
|
+
* add `.parse` export
|
47
|
+
|
48
|
+
2.0.2 / 2015-05-20
|
49
|
+
==================
|
50
|
+
|
51
|
+
* remove map recreation
|
52
|
+
* remove unnecessary object construction
|
53
|
+
|
54
|
+
2.0.1 / 2015-05-07
|
55
|
+
==================
|
56
|
+
|
57
|
+
* fix browserify require
|
58
|
+
* remove node.extend dependency
|
59
|
+
|
60
|
+
2.0.0 / 2015-04-12
|
61
|
+
==================
|
62
|
+
|
63
|
+
* add option "case"
|
64
|
+
* add option "thousandsSeparator"
|
65
|
+
* return "null" on invalid parse input
|
66
|
+
* support proper round-trip: bytes(bytes(num)) === num
|
67
|
+
* units no longer case sensitive when parsing
|
68
|
+
|
69
|
+
1.0.0 / 2014-05-05
|
70
|
+
==================
|
71
|
+
|
72
|
+
* add negative support. fixes #6
|
73
|
+
|
74
|
+
0.3.0 / 2014-03-19
|
75
|
+
==================
|
76
|
+
|
77
|
+
* added terabyte support
|
78
|
+
|
79
|
+
0.2.1 / 2013-04-01
|
80
|
+
==================
|
81
|
+
|
82
|
+
* add .component
|
83
|
+
|
84
|
+
0.2.0 / 2012-10-28
|
85
|
+
==================
|
86
|
+
|
87
|
+
* bytes(200).should.eql('200b')
|
88
|
+
|
89
|
+
0.1.0 / 2012-07-04
|
90
|
+
==================
|
91
|
+
|
92
|
+
* add bytes to string conversion [yields]
|
@@ -0,0 +1,23 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2012-2014 TJ Holowaychuk <tj@vision-media.ca>
|
4
|
+
Copyright (c) 2015 Jed Watson <jed.watson@me.com>
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
a copy of this software and associated documentation files (the
|
8
|
+
'Software'), to deal in the Software without restriction, including
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
20
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
21
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
22
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
23
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,152 @@
|
|
1
|
+
# Bytes utility
|
2
|
+
|
3
|
+
[![NPM Version][npm-image]][npm-url]
|
4
|
+
[![NPM Downloads][downloads-image]][downloads-url]
|
5
|
+
[![Build Status][ci-image]][ci-url]
|
6
|
+
[![Test Coverage][coveralls-image]][coveralls-url]
|
7
|
+
|
8
|
+
Utility to parse a string bytes (ex: `1TB`) to bytes (`1099511627776`) and vice-versa.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
This is a [Node.js](https://nodejs.org/en/) module available through the
|
13
|
+
[npm registry](https://www.npmjs.com/). Installation is done using the
|
14
|
+
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
15
|
+
|
16
|
+
```bash
|
17
|
+
$ npm install bytes
|
18
|
+
```
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
```js
|
23
|
+
var bytes = require('bytes');
|
24
|
+
```
|
25
|
+
|
26
|
+
#### bytes(number|string value, [options]): number|string|null
|
27
|
+
|
28
|
+
Default export function. Delegates to either `bytes.format` or `bytes.parse` based on the type of `value`.
|
29
|
+
|
30
|
+
**Arguments**
|
31
|
+
|
32
|
+
| Name | Type | Description |
|
33
|
+
|---------|----------|--------------------|
|
34
|
+
| value | `number`|`string` | Number value to format or string value to parse |
|
35
|
+
| options | `Object` | Conversion options for `format` |
|
36
|
+
|
37
|
+
**Returns**
|
38
|
+
|
39
|
+
| Name | Type | Description |
|
40
|
+
|---------|------------------|-------------------------------------------------|
|
41
|
+
| results | `string`|`number`|`null` | Return null upon error. Numeric value in bytes, or string value otherwise. |
|
42
|
+
|
43
|
+
**Example**
|
44
|
+
|
45
|
+
```js
|
46
|
+
bytes(1024);
|
47
|
+
// output: '1KB'
|
48
|
+
|
49
|
+
bytes('1KB');
|
50
|
+
// output: 1024
|
51
|
+
```
|
52
|
+
|
53
|
+
#### bytes.format(number value, [options]): string|null
|
54
|
+
|
55
|
+
Format the given value in bytes into a string. If the value is negative, it is kept as such. If it is a float, it is
|
56
|
+
rounded.
|
57
|
+
|
58
|
+
**Arguments**
|
59
|
+
|
60
|
+
| Name | Type | Description |
|
61
|
+
|---------|----------|--------------------|
|
62
|
+
| value | `number` | Value in bytes |
|
63
|
+
| options | `Object` | Conversion options |
|
64
|
+
|
65
|
+
**Options**
|
66
|
+
|
67
|
+
| Property | Type | Description |
|
68
|
+
|-------------------|--------|-----------------------------------------------------------------------------------------|
|
69
|
+
| decimalPlaces | `number`|`null` | Maximum number of decimal places to include in output. Default value to `2`. |
|
70
|
+
| fixedDecimals | `boolean`|`null` | Whether to always display the maximum number of decimal places. Default value to `false` |
|
71
|
+
| thousandsSeparator | `string`|`null` | Example of values: `' '`, `','` and `'.'`... Default value to `''`. |
|
72
|
+
| unit | `string`|`null` | The unit in which the result will be returned (B/KB/MB/GB/TB). Default value to `''` (which means auto detect). |
|
73
|
+
| unitSeparator | `string`|`null` | Separator to use between number and unit. Default value to `''`. |
|
74
|
+
|
75
|
+
**Returns**
|
76
|
+
|
77
|
+
| Name | Type | Description |
|
78
|
+
|---------|------------------|-------------------------------------------------|
|
79
|
+
| results | `string`|`null` | Return null upon error. String value otherwise. |
|
80
|
+
|
81
|
+
**Example**
|
82
|
+
|
83
|
+
```js
|
84
|
+
bytes.format(1024);
|
85
|
+
// output: '1KB'
|
86
|
+
|
87
|
+
bytes.format(1000);
|
88
|
+
// output: '1000B'
|
89
|
+
|
90
|
+
bytes.format(1000, {thousandsSeparator: ' '});
|
91
|
+
// output: '1 000B'
|
92
|
+
|
93
|
+
bytes.format(1024 * 1.7, {decimalPlaces: 0});
|
94
|
+
// output: '2KB'
|
95
|
+
|
96
|
+
bytes.format(1024, {unitSeparator: ' '});
|
97
|
+
// output: '1 KB'
|
98
|
+
```
|
99
|
+
|
100
|
+
#### bytes.parse(string|number value): number|null
|
101
|
+
|
102
|
+
Parse the string value into an integer in bytes. If no unit is given, or `value`
|
103
|
+
is a number, it is assumed the value is in bytes.
|
104
|
+
|
105
|
+
Supported units and abbreviations are as follows and are case-insensitive:
|
106
|
+
|
107
|
+
* `b` for bytes
|
108
|
+
* `kb` for kilobytes
|
109
|
+
* `mb` for megabytes
|
110
|
+
* `gb` for gigabytes
|
111
|
+
* `tb` for terabytes
|
112
|
+
* `pb` for petabytes
|
113
|
+
|
114
|
+
The units are in powers of two, not ten. This means 1kb = 1024b according to this parser.
|
115
|
+
|
116
|
+
**Arguments**
|
117
|
+
|
118
|
+
| Name | Type | Description |
|
119
|
+
|---------------|--------|--------------------|
|
120
|
+
| value | `string`|`number` | String to parse, or number in bytes. |
|
121
|
+
|
122
|
+
**Returns**
|
123
|
+
|
124
|
+
| Name | Type | Description |
|
125
|
+
|---------|-------------|-------------------------|
|
126
|
+
| results | `number`|`null` | Return null upon error. Value in bytes otherwise. |
|
127
|
+
|
128
|
+
**Example**
|
129
|
+
|
130
|
+
```js
|
131
|
+
bytes.parse('1KB');
|
132
|
+
// output: 1024
|
133
|
+
|
134
|
+
bytes.parse('1024');
|
135
|
+
// output: 1024
|
136
|
+
|
137
|
+
bytes.parse(1024);
|
138
|
+
// output: 1024
|
139
|
+
```
|
140
|
+
|
141
|
+
## License
|
142
|
+
|
143
|
+
[MIT](LICENSE)
|
144
|
+
|
145
|
+
[ci-image]: https://badgen.net/github/checks/visionmedia/bytes.js/master?label=ci
|
146
|
+
[ci-url]: https://github.com/visionmedia/bytes.js/actions?query=workflow%3Aci
|
147
|
+
[coveralls-image]: https://badgen.net/coveralls/c/github/visionmedia/bytes.js/master
|
148
|
+
[coveralls-url]: https://coveralls.io/r/visionmedia/bytes.js?branch=master
|
149
|
+
[downloads-image]: https://badgen.net/npm/dm/bytes
|
150
|
+
[downloads-url]: https://npmjs.org/package/bytes
|
151
|
+
[npm-image]: https://badgen.net/npm/v/bytes
|
152
|
+
[npm-url]: https://npmjs.org/package/bytes
|