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,45 @@
|
|
1
|
+
{
|
2
|
+
"name": "type-is",
|
3
|
+
"description": "Infer the content-type of a request.",
|
4
|
+
"version": "1.6.18",
|
5
|
+
"contributors": [
|
6
|
+
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
7
|
+
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
|
8
|
+
],
|
9
|
+
"license": "MIT",
|
10
|
+
"repository": "jshttp/type-is",
|
11
|
+
"dependencies": {
|
12
|
+
"media-typer": "0.3.0",
|
13
|
+
"mime-types": "~2.1.24"
|
14
|
+
},
|
15
|
+
"devDependencies": {
|
16
|
+
"eslint": "5.16.0",
|
17
|
+
"eslint-config-standard": "12.0.0",
|
18
|
+
"eslint-plugin-import": "2.17.2",
|
19
|
+
"eslint-plugin-markdown": "1.0.0",
|
20
|
+
"eslint-plugin-node": "8.0.1",
|
21
|
+
"eslint-plugin-promise": "4.1.1",
|
22
|
+
"eslint-plugin-standard": "4.0.0",
|
23
|
+
"mocha": "6.1.4",
|
24
|
+
"nyc": "14.0.0"
|
25
|
+
},
|
26
|
+
"engines": {
|
27
|
+
"node": ">= 0.6"
|
28
|
+
},
|
29
|
+
"files": [
|
30
|
+
"LICENSE",
|
31
|
+
"HISTORY.md",
|
32
|
+
"index.js"
|
33
|
+
],
|
34
|
+
"scripts": {
|
35
|
+
"lint": "eslint --plugin markdown --ext js,md .",
|
36
|
+
"test": "mocha --reporter spec --check-leaks --bail test/",
|
37
|
+
"test-cov": "nyc --reporter=html --reporter=text npm test",
|
38
|
+
"test-travis": "nyc --reporter=text npm test"
|
39
|
+
},
|
40
|
+
"keywords": [
|
41
|
+
"content",
|
42
|
+
"type",
|
43
|
+
"checking"
|
44
|
+
]
|
45
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# unpipe
|
2
|
+
|
3
|
+
[![NPM Version][npm-image]][npm-url]
|
4
|
+
[![NPM Downloads][downloads-image]][downloads-url]
|
5
|
+
[![Node.js Version][node-image]][node-url]
|
6
|
+
[![Build Status][travis-image]][travis-url]
|
7
|
+
[![Test Coverage][coveralls-image]][coveralls-url]
|
8
|
+
|
9
|
+
Unpipe a stream from all destinations.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
```sh
|
14
|
+
$ npm install unpipe
|
15
|
+
```
|
16
|
+
|
17
|
+
## API
|
18
|
+
|
19
|
+
```js
|
20
|
+
var unpipe = require('unpipe')
|
21
|
+
```
|
22
|
+
|
23
|
+
### unpipe(stream)
|
24
|
+
|
25
|
+
Unpipes all destinations from a given stream. With stream 2+, this is
|
26
|
+
equivalent to `stream.unpipe()`. When used with streams 1 style streams
|
27
|
+
(typically Node.js 0.8 and below), this module attempts to undo the
|
28
|
+
actions done in `stream.pipe(dest)`.
|
29
|
+
|
30
|
+
## License
|
31
|
+
|
32
|
+
[MIT](LICENSE)
|
33
|
+
|
34
|
+
[npm-image]: https://img.shields.io/npm/v/unpipe.svg
|
35
|
+
[npm-url]: https://npmjs.org/package/unpipe
|
36
|
+
[node-image]: https://img.shields.io/node/v/unpipe.svg
|
37
|
+
[node-url]: http://nodejs.org/download/
|
38
|
+
[travis-image]: https://img.shields.io/travis/stream-utils/unpipe.svg
|
39
|
+
[travis-url]: https://travis-ci.org/stream-utils/unpipe
|
40
|
+
[coveralls-image]: https://img.shields.io/coveralls/stream-utils/unpipe.svg
|
41
|
+
[coveralls-url]: https://coveralls.io/r/stream-utils/unpipe?branch=master
|
42
|
+
[downloads-image]: https://img.shields.io/npm/dm/unpipe.svg
|
43
|
+
[downloads-url]: https://npmjs.org/package/unpipe
|
@@ -0,0 +1,69 @@
|
|
1
|
+
/*!
|
2
|
+
* unpipe
|
3
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
4
|
+
* MIT Licensed
|
5
|
+
*/
|
6
|
+
|
7
|
+
'use strict'
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Module exports.
|
11
|
+
* @public
|
12
|
+
*/
|
13
|
+
|
14
|
+
module.exports = unpipe
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Determine if there are Node.js pipe-like data listeners.
|
18
|
+
* @private
|
19
|
+
*/
|
20
|
+
|
21
|
+
function hasPipeDataListeners(stream) {
|
22
|
+
var listeners = stream.listeners('data')
|
23
|
+
|
24
|
+
for (var i = 0; i < listeners.length; i++) {
|
25
|
+
if (listeners[i].name === 'ondata') {
|
26
|
+
return true
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
return false
|
31
|
+
}
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Unpipe a stream from all destinations.
|
35
|
+
*
|
36
|
+
* @param {object} stream
|
37
|
+
* @public
|
38
|
+
*/
|
39
|
+
|
40
|
+
function unpipe(stream) {
|
41
|
+
if (!stream) {
|
42
|
+
throw new TypeError('argument stream is required')
|
43
|
+
}
|
44
|
+
|
45
|
+
if (typeof stream.unpipe === 'function') {
|
46
|
+
// new-style
|
47
|
+
stream.unpipe()
|
48
|
+
return
|
49
|
+
}
|
50
|
+
|
51
|
+
// Node.js 0.8 hack
|
52
|
+
if (!hasPipeDataListeners(stream)) {
|
53
|
+
return
|
54
|
+
}
|
55
|
+
|
56
|
+
var listener
|
57
|
+
var listeners = stream.listeners('close')
|
58
|
+
|
59
|
+
for (var i = 0; i < listeners.length; i++) {
|
60
|
+
listener = listeners[i]
|
61
|
+
|
62
|
+
if (listener.name !== 'cleanup' && listener.name !== 'onclose') {
|
63
|
+
continue
|
64
|
+
}
|
65
|
+
|
66
|
+
// invoke the listener
|
67
|
+
listener.call(stream)
|
68
|
+
}
|
69
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
{
|
2
|
+
"name": "unpipe",
|
3
|
+
"description": "Unpipe a stream from all destinations",
|
4
|
+
"version": "1.0.0",
|
5
|
+
"author": "Douglas Christopher Wilson <doug@somethingdoug.com>",
|
6
|
+
"license": "MIT",
|
7
|
+
"repository": "stream-utils/unpipe",
|
8
|
+
"devDependencies": {
|
9
|
+
"istanbul": "0.3.15",
|
10
|
+
"mocha": "2.2.5",
|
11
|
+
"readable-stream": "1.1.13"
|
12
|
+
},
|
13
|
+
"files": [
|
14
|
+
"HISTORY.md",
|
15
|
+
"LICENSE",
|
16
|
+
"README.md",
|
17
|
+
"index.js"
|
18
|
+
],
|
19
|
+
"engines": {
|
20
|
+
"node": ">= 0.8"
|
21
|
+
},
|
22
|
+
"scripts": {
|
23
|
+
"test": "mocha --reporter spec --bail --check-leaks test/",
|
24
|
+
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
|
25
|
+
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
|
26
|
+
}
|
27
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013-2017 Jared Hanson
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# utils-merge
|
2
|
+
|
3
|
+
[](https://www.npmjs.com/package/utils-merge)
|
4
|
+
[](https://travis-ci.org/jaredhanson/utils-merge)
|
5
|
+
[](https://codeclimate.com/github/jaredhanson/utils-merge)
|
6
|
+
[](https://coveralls.io/r/jaredhanson/utils-merge)
|
7
|
+
[](https://david-dm.org/jaredhanson/utils-merge)
|
8
|
+
|
9
|
+
|
10
|
+
Merges the properties from a source object into a destination object.
|
11
|
+
|
12
|
+
## Install
|
13
|
+
|
14
|
+
```bash
|
15
|
+
$ npm install utils-merge
|
16
|
+
```
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
```javascript
|
21
|
+
var a = { foo: 'bar' }
|
22
|
+
, b = { bar: 'baz' };
|
23
|
+
|
24
|
+
merge(a, b);
|
25
|
+
// => { foo: 'bar', bar: 'baz' }
|
26
|
+
```
|
27
|
+
|
28
|
+
## License
|
29
|
+
|
30
|
+
[The MIT License](http://opensource.org/licenses/MIT)
|
31
|
+
|
32
|
+
Copyright (c) 2013-2017 Jared Hanson <[http://jaredhanson.net/](http://jaredhanson.net/)>
|
33
|
+
|
34
|
+
<a target='_blank' rel='nofollow' href='https://app.codesponsor.io/link/vK9dyjRnnWsMzzJTQ57fRJpH/jaredhanson/utils-merge'> <img alt='Sponsor' width='888' height='68' src='https://app.codesponsor.io/embed/vK9dyjRnnWsMzzJTQ57fRJpH/jaredhanson/utils-merge.svg' /></a>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
/**
|
2
|
+
* Merge object b with object a.
|
3
|
+
*
|
4
|
+
* var a = { foo: 'bar' }
|
5
|
+
* , b = { bar: 'baz' };
|
6
|
+
*
|
7
|
+
* merge(a, b);
|
8
|
+
* // => { foo: 'bar', bar: 'baz' }
|
9
|
+
*
|
10
|
+
* @param {Object} a
|
11
|
+
* @param {Object} b
|
12
|
+
* @return {Object}
|
13
|
+
* @api public
|
14
|
+
*/
|
15
|
+
|
16
|
+
exports = module.exports = function(a, b){
|
17
|
+
if (a && b) {
|
18
|
+
for (var key in b) {
|
19
|
+
a[key] = b[key];
|
20
|
+
}
|
21
|
+
}
|
22
|
+
return a;
|
23
|
+
};
|
@@ -0,0 +1,40 @@
|
|
1
|
+
{
|
2
|
+
"name": "utils-merge",
|
3
|
+
"version": "1.0.1",
|
4
|
+
"description": "merge() utility function",
|
5
|
+
"keywords": [
|
6
|
+
"util"
|
7
|
+
],
|
8
|
+
"author": {
|
9
|
+
"name": "Jared Hanson",
|
10
|
+
"email": "jaredhanson@gmail.com",
|
11
|
+
"url": "http://www.jaredhanson.net/"
|
12
|
+
},
|
13
|
+
"repository": {
|
14
|
+
"type": "git",
|
15
|
+
"url": "git://github.com/jaredhanson/utils-merge.git"
|
16
|
+
},
|
17
|
+
"bugs": {
|
18
|
+
"url": "http://github.com/jaredhanson/utils-merge/issues"
|
19
|
+
},
|
20
|
+
"license": "MIT",
|
21
|
+
"licenses": [
|
22
|
+
{
|
23
|
+
"type": "MIT",
|
24
|
+
"url": "http://opensource.org/licenses/MIT"
|
25
|
+
}
|
26
|
+
],
|
27
|
+
"main": "./index",
|
28
|
+
"dependencies": {},
|
29
|
+
"devDependencies": {
|
30
|
+
"make-node": "0.3.x",
|
31
|
+
"mocha": "1.x.x",
|
32
|
+
"chai": "1.x.x"
|
33
|
+
},
|
34
|
+
"engines": {
|
35
|
+
"node": ">= 0.4.0"
|
36
|
+
},
|
37
|
+
"scripts": {
|
38
|
+
"test": "node_modules/.bin/mocha --reporter spec --require test/bootstrap/node test/*.test.js"
|
39
|
+
}
|
40
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
1.1.2 / 2017-09-23
|
2
|
+
==================
|
3
|
+
|
4
|
+
* perf: improve header token parsing speed
|
5
|
+
|
6
|
+
1.1.1 / 2017-03-20
|
7
|
+
==================
|
8
|
+
|
9
|
+
* perf: hoist regular expression
|
10
|
+
|
11
|
+
1.1.0 / 2015-09-29
|
12
|
+
==================
|
13
|
+
|
14
|
+
* Only accept valid field names in the `field` argument
|
15
|
+
- Ensures the resulting string is a valid HTTP header value
|
16
|
+
|
17
|
+
1.0.1 / 2015-07-08
|
18
|
+
==================
|
19
|
+
|
20
|
+
* Fix setting empty header from empty `field`
|
21
|
+
* perf: enable strict mode
|
22
|
+
* perf: remove argument reassignments
|
23
|
+
|
24
|
+
1.0.0 / 2014-08-10
|
25
|
+
==================
|
26
|
+
|
27
|
+
* Accept valid `Vary` header string as `field`
|
28
|
+
* Add `vary.append` for low-level string manipulation
|
29
|
+
* Move to `jshttp` orgainzation
|
30
|
+
|
31
|
+
0.1.0 / 2014-06-05
|
32
|
+
==================
|
33
|
+
|
34
|
+
* Support array of fields to set
|
35
|
+
|
36
|
+
0.0.0 / 2014-06-04
|
37
|
+
==================
|
38
|
+
|
39
|
+
* Initial release
|
@@ -0,0 +1,22 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2014-2017 Douglas Christopher Wilson
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# vary
|
2
|
+
|
3
|
+
[![NPM Version][npm-image]][npm-url]
|
4
|
+
[![NPM Downloads][downloads-image]][downloads-url]
|
5
|
+
[![Node.js Version][node-version-image]][node-version-url]
|
6
|
+
[![Build Status][travis-image]][travis-url]
|
7
|
+
[![Test Coverage][coveralls-image]][coveralls-url]
|
8
|
+
|
9
|
+
Manipulate the HTTP Vary header
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
This is a [Node.js](https://nodejs.org/en/) module available through the
|
14
|
+
[npm registry](https://www.npmjs.com/). Installation is done using the
|
15
|
+
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
16
|
+
|
17
|
+
```sh
|
18
|
+
$ npm install vary
|
19
|
+
```
|
20
|
+
|
21
|
+
## API
|
22
|
+
|
23
|
+
<!-- eslint-disable no-unused-vars -->
|
24
|
+
|
25
|
+
```js
|
26
|
+
var vary = require('vary')
|
27
|
+
```
|
28
|
+
|
29
|
+
### vary(res, field)
|
30
|
+
|
31
|
+
Adds the given header `field` to the `Vary` response header of `res`.
|
32
|
+
This can be a string of a single field, a string of a valid `Vary`
|
33
|
+
header, or an array of multiple fields.
|
34
|
+
|
35
|
+
This will append the header if not already listed, otherwise leaves
|
36
|
+
it listed in the current location.
|
37
|
+
|
38
|
+
<!-- eslint-disable no-undef -->
|
39
|
+
|
40
|
+
```js
|
41
|
+
// Append "Origin" to the Vary header of the response
|
42
|
+
vary(res, 'Origin')
|
43
|
+
```
|
44
|
+
|
45
|
+
### vary.append(header, field)
|
46
|
+
|
47
|
+
Adds the given header `field` to the `Vary` response header string `header`.
|
48
|
+
This can be a string of a single field, a string of a valid `Vary` header,
|
49
|
+
or an array of multiple fields.
|
50
|
+
|
51
|
+
This will append the header if not already listed, otherwise leaves
|
52
|
+
it listed in the current location. The new header string is returned.
|
53
|
+
|
54
|
+
<!-- eslint-disable no-undef -->
|
55
|
+
|
56
|
+
```js
|
57
|
+
// Get header string appending "Origin" to "Accept, User-Agent"
|
58
|
+
vary.append('Accept, User-Agent', 'Origin')
|
59
|
+
```
|
60
|
+
|
61
|
+
## Examples
|
62
|
+
|
63
|
+
### Updating the Vary header when content is based on it
|
64
|
+
|
65
|
+
```js
|
66
|
+
var http = require('http')
|
67
|
+
var vary = require('vary')
|
68
|
+
|
69
|
+
http.createServer(function onRequest (req, res) {
|
70
|
+
// about to user-agent sniff
|
71
|
+
vary(res, 'User-Agent')
|
72
|
+
|
73
|
+
var ua = req.headers['user-agent'] || ''
|
74
|
+
var isMobile = /mobi|android|touch|mini/i.test(ua)
|
75
|
+
|
76
|
+
// serve site, depending on isMobile
|
77
|
+
res.setHeader('Content-Type', 'text/html')
|
78
|
+
res.end('You are (probably) ' + (isMobile ? '' : 'not ') + 'a mobile user')
|
79
|
+
})
|
80
|
+
```
|
81
|
+
|
82
|
+
## Testing
|
83
|
+
|
84
|
+
```sh
|
85
|
+
$ npm test
|
86
|
+
```
|
87
|
+
|
88
|
+
## License
|
89
|
+
|
90
|
+
[MIT](LICENSE)
|
91
|
+
|
92
|
+
[npm-image]: https://img.shields.io/npm/v/vary.svg
|
93
|
+
[npm-url]: https://npmjs.org/package/vary
|
94
|
+
[node-version-image]: https://img.shields.io/node/v/vary.svg
|
95
|
+
[node-version-url]: https://nodejs.org/en/download
|
96
|
+
[travis-image]: https://img.shields.io/travis/jshttp/vary/master.svg
|
97
|
+
[travis-url]: https://travis-ci.org/jshttp/vary
|
98
|
+
[coveralls-image]: https://img.shields.io/coveralls/jshttp/vary/master.svg
|
99
|
+
[coveralls-url]: https://coveralls.io/r/jshttp/vary
|
100
|
+
[downloads-image]: https://img.shields.io/npm/dm/vary.svg
|
101
|
+
[downloads-url]: https://npmjs.org/package/vary
|
@@ -0,0 +1,149 @@
|
|
1
|
+
/*!
|
2
|
+
* vary
|
3
|
+
* Copyright(c) 2014-2017 Douglas Christopher Wilson
|
4
|
+
* MIT Licensed
|
5
|
+
*/
|
6
|
+
|
7
|
+
'use strict'
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Module exports.
|
11
|
+
*/
|
12
|
+
|
13
|
+
module.exports = vary
|
14
|
+
module.exports.append = append
|
15
|
+
|
16
|
+
/**
|
17
|
+
* RegExp to match field-name in RFC 7230 sec 3.2
|
18
|
+
*
|
19
|
+
* field-name = token
|
20
|
+
* token = 1*tchar
|
21
|
+
* tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*"
|
22
|
+
* / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
|
23
|
+
* / DIGIT / ALPHA
|
24
|
+
* ; any VCHAR, except delimiters
|
25
|
+
*/
|
26
|
+
|
27
|
+
var FIELD_NAME_REGEXP = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Append a field to a vary header.
|
31
|
+
*
|
32
|
+
* @param {String} header
|
33
|
+
* @param {String|Array} field
|
34
|
+
* @return {String}
|
35
|
+
* @public
|
36
|
+
*/
|
37
|
+
|
38
|
+
function append (header, field) {
|
39
|
+
if (typeof header !== 'string') {
|
40
|
+
throw new TypeError('header argument is required')
|
41
|
+
}
|
42
|
+
|
43
|
+
if (!field) {
|
44
|
+
throw new TypeError('field argument is required')
|
45
|
+
}
|
46
|
+
|
47
|
+
// get fields array
|
48
|
+
var fields = !Array.isArray(field)
|
49
|
+
? parse(String(field))
|
50
|
+
: field
|
51
|
+
|
52
|
+
// assert on invalid field names
|
53
|
+
for (var j = 0; j < fields.length; j++) {
|
54
|
+
if (!FIELD_NAME_REGEXP.test(fields[j])) {
|
55
|
+
throw new TypeError('field argument contains an invalid header name')
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
// existing, unspecified vary
|
60
|
+
if (header === '*') {
|
61
|
+
return header
|
62
|
+
}
|
63
|
+
|
64
|
+
// enumerate current values
|
65
|
+
var val = header
|
66
|
+
var vals = parse(header.toLowerCase())
|
67
|
+
|
68
|
+
// unspecified vary
|
69
|
+
if (fields.indexOf('*') !== -1 || vals.indexOf('*') !== -1) {
|
70
|
+
return '*'
|
71
|
+
}
|
72
|
+
|
73
|
+
for (var i = 0; i < fields.length; i++) {
|
74
|
+
var fld = fields[i].toLowerCase()
|
75
|
+
|
76
|
+
// append value (case-preserving)
|
77
|
+
if (vals.indexOf(fld) === -1) {
|
78
|
+
vals.push(fld)
|
79
|
+
val = val
|
80
|
+
? val + ', ' + fields[i]
|
81
|
+
: fields[i]
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
return val
|
86
|
+
}
|
87
|
+
|
88
|
+
/**
|
89
|
+
* Parse a vary header into an array.
|
90
|
+
*
|
91
|
+
* @param {String} header
|
92
|
+
* @return {Array}
|
93
|
+
* @private
|
94
|
+
*/
|
95
|
+
|
96
|
+
function parse (header) {
|
97
|
+
var end = 0
|
98
|
+
var list = []
|
99
|
+
var start = 0
|
100
|
+
|
101
|
+
// gather tokens
|
102
|
+
for (var i = 0, len = header.length; i < len; i++) {
|
103
|
+
switch (header.charCodeAt(i)) {
|
104
|
+
case 0x20: /* */
|
105
|
+
if (start === end) {
|
106
|
+
start = end = i + 1
|
107
|
+
}
|
108
|
+
break
|
109
|
+
case 0x2c: /* , */
|
110
|
+
list.push(header.substring(start, end))
|
111
|
+
start = end = i + 1
|
112
|
+
break
|
113
|
+
default:
|
114
|
+
end = i + 1
|
115
|
+
break
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
119
|
+
// final token
|
120
|
+
list.push(header.substring(start, end))
|
121
|
+
|
122
|
+
return list
|
123
|
+
}
|
124
|
+
|
125
|
+
/**
|
126
|
+
* Mark that a request is varied on a header field.
|
127
|
+
*
|
128
|
+
* @param {Object} res
|
129
|
+
* @param {String|Array} field
|
130
|
+
* @public
|
131
|
+
*/
|
132
|
+
|
133
|
+
function vary (res, field) {
|
134
|
+
if (!res || !res.getHeader || !res.setHeader) {
|
135
|
+
// quack quack
|
136
|
+
throw new TypeError('res argument is required')
|
137
|
+
}
|
138
|
+
|
139
|
+
// get existing header
|
140
|
+
var val = res.getHeader('Vary') || ''
|
141
|
+
var header = Array.isArray(val)
|
142
|
+
? val.join(', ')
|
143
|
+
: String(val)
|
144
|
+
|
145
|
+
// set new header
|
146
|
+
if ((val = append(header, field))) {
|
147
|
+
res.setHeader('Vary', val)
|
148
|
+
}
|
149
|
+
}
|