webpack_rails 0.3.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/webpack_rails/ErrorMessagePlugin.js +37 -0
- data/lib/webpack_rails/engine.rb +6 -5
- data/lib/webpack_rails/node_modules/cors/CONTRIBUTING.md +35 -0
- data/lib/webpack_rails/node_modules/cors/LICENSE +9 -0
- data/lib/webpack_rails/node_modules/cors/README.md +192 -0
- data/lib/webpack_rails/node_modules/cors/lib/index.js +242 -0
- data/lib/webpack_rails/node_modules/cors/node_modules/vary/HISTORY.md +29 -0
- data/lib/webpack_rails/node_modules/cors/node_modules/vary/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/cors/node_modules/vary/README.md +91 -0
- data/lib/webpack_rails/node_modules/cors/node_modules/vary/index.js +124 -0
- data/lib/webpack_rails/node_modules/cors/node_modules/vary/package.json +72 -0
- data/lib/webpack_rails/node_modules/cors/package.json +79 -0
- data/lib/webpack_rails/node_modules/cors/test/basic-auth.js +40 -0
- data/lib/webpack_rails/node_modules/cors/test/body-events.js +81 -0
- data/lib/webpack_rails/node_modules/cors/test/cors.js +652 -0
- data/lib/webpack_rails/node_modules/cors/test/error-response.js +77 -0
- data/lib/webpack_rails/node_modules/cors/test/example-app.js +98 -0
- data/lib/webpack_rails/node_modules/cors/test/issue-2.js +56 -0
- data/lib/webpack_rails/node_modules/cors/test/issue-31.js +58 -0
- data/lib/webpack_rails/node_modules/cors/test/mocha.opts +3 -0
- data/lib/webpack_rails/node_modules/express/History.md +3025 -0
- data/lib/webpack_rails/node_modules/express/LICENSE +24 -0
- data/lib/webpack_rails/node_modules/express/Readme.md +138 -0
- data/lib/webpack_rails/node_modules/express/index.js +11 -0
- data/lib/webpack_rails/node_modules/express/lib/application.js +643 -0
- data/lib/webpack_rails/node_modules/express/lib/express.js +103 -0
- data/lib/webpack_rails/node_modules/express/lib/middleware/init.js +36 -0
- data/lib/webpack_rails/node_modules/express/lib/middleware/query.js +51 -0
- data/lib/webpack_rails/node_modules/express/lib/request.js +489 -0
- data/lib/webpack_rails/node_modules/express/lib/response.js +1053 -0
- data/lib/webpack_rails/node_modules/express/lib/router/index.js +645 -0
- data/lib/webpack_rails/node_modules/express/lib/router/layer.js +176 -0
- data/lib/webpack_rails/node_modules/express/lib/router/route.js +210 -0
- data/lib/webpack_rails/node_modules/express/lib/utils.js +300 -0
- data/lib/webpack_rails/node_modules/express/lib/view.js +173 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/HISTORY.md +170 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/LICENSE +23 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/README.md +135 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/index.js +231 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/mime-types/HISTORY.md +171 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/mime-types/LICENSE +23 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/mime-types/README.md +103 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/mime-types/index.js +188 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/HISTORY.md +274 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/README.md +82 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/db.json +6474 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/index.js +11 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/package.json +94 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/mime-types/package.json +84 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/negotiator/HISTORY.md +76 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/negotiator/LICENSE +24 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/negotiator/README.md +203 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/negotiator/index.js +62 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/charset.js +102 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/encoding.js +118 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/language.js +112 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/mediaType.js +179 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/negotiator/package.json +86 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/package.json +98 -0
- data/lib/webpack_rails/node_modules/express/node_modules/array-flatten/LICENSE +21 -0
- data/lib/webpack_rails/node_modules/express/node_modules/array-flatten/README.md +43 -0
- data/lib/webpack_rails/node_modules/express/node_modules/array-flatten/array-flatten.js +64 -0
- data/lib/webpack_rails/node_modules/express/node_modules/array-flatten/package.json +62 -0
- data/lib/webpack_rails/node_modules/express/node_modules/content-disposition/HISTORY.md +40 -0
- data/lib/webpack_rails/node_modules/express/node_modules/content-disposition/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/content-disposition/README.md +141 -0
- data/lib/webpack_rails/node_modules/express/node_modules/content-disposition/index.js +443 -0
- data/lib/webpack_rails/node_modules/express/node_modules/content-disposition/package.json +66 -0
- data/lib/webpack_rails/node_modules/express/node_modules/content-type/HISTORY.md +9 -0
- data/lib/webpack_rails/node_modules/express/node_modules/content-type/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/content-type/README.md +92 -0
- data/lib/webpack_rails/node_modules/express/node_modules/content-type/index.js +214 -0
- data/lib/webpack_rails/node_modules/express/node_modules/content-type/package.json +65 -0
- data/lib/webpack_rails/node_modules/express/node_modules/cookie/LICENSE +23 -0
- data/lib/webpack_rails/node_modules/express/node_modules/cookie/README.md +64 -0
- data/lib/webpack_rails/node_modules/express/node_modules/cookie/index.js +116 -0
- data/lib/webpack_rails/node_modules/express/node_modules/cookie/package.json +68 -0
- data/lib/webpack_rails/node_modules/express/node_modules/cookie-signature/History.md +38 -0
- data/lib/webpack_rails/node_modules/express/node_modules/cookie-signature/Readme.md +42 -0
- data/lib/webpack_rails/node_modules/express/node_modules/cookie-signature/index.js +51 -0
- data/lib/webpack_rails/node_modules/express/node_modules/cookie-signature/package.json +59 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/History.md +195 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/Makefile +36 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/Readme.md +188 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/bower.json +28 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/browser.js +168 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/component.json +19 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/debug.js +197 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/node.js +209 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/node_modules/ms/History.md +66 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/node_modules/ms/LICENSE +20 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/node_modules/ms/README.md +35 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/node_modules/ms/index.js +125 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/node_modules/ms/package.json +47 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/package.json +73 -0
- data/lib/webpack_rails/node_modules/express/node_modules/depd/History.md +75 -0
- data/lib/webpack_rails/node_modules/express/node_modules/depd/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/depd/Readme.md +274 -0
- data/lib/webpack_rails/node_modules/express/node_modules/depd/index.js +529 -0
- data/lib/webpack_rails/node_modules/express/node_modules/depd/lib/compat/buffer-concat.js +33 -0
- data/lib/webpack_rails/node_modules/express/node_modules/depd/lib/compat/callsite-tostring.js +101 -0
- data/lib/webpack_rails/node_modules/express/node_modules/depd/lib/compat/index.js +69 -0
- data/lib/webpack_rails/node_modules/express/node_modules/depd/package.json +66 -0
- data/lib/webpack_rails/node_modules/express/node_modules/escape-html/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/escape-html/Readme.md +15 -0
- data/lib/webpack_rails/node_modules/express/node_modules/escape-html/index.js +29 -0
- data/lib/webpack_rails/node_modules/express/node_modules/escape-html/package.json +51 -0
- data/lib/webpack_rails/node_modules/express/node_modules/etag/HISTORY.md +71 -0
- data/lib/webpack_rails/node_modules/express/node_modules/etag/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/etag/README.md +165 -0
- data/lib/webpack_rails/node_modules/express/node_modules/etag/index.js +132 -0
- data/lib/webpack_rails/node_modules/express/node_modules/etag/package.json +73 -0
- data/lib/webpack_rails/node_modules/express/node_modules/finalhandler/HISTORY.md +90 -0
- data/lib/webpack_rails/node_modules/express/node_modules/finalhandler/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/finalhandler/README.md +133 -0
- data/lib/webpack_rails/node_modules/express/node_modules/finalhandler/index.js +151 -0
- data/lib/webpack_rails/node_modules/express/node_modules/finalhandler/node_modules/unpipe/HISTORY.md +4 -0
- data/lib/webpack_rails/node_modules/express/node_modules/finalhandler/node_modules/unpipe/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/finalhandler/node_modules/unpipe/README.md +43 -0
- data/lib/webpack_rails/node_modules/express/node_modules/finalhandler/node_modules/unpipe/index.js +69 -0
- data/lib/webpack_rails/node_modules/express/node_modules/finalhandler/node_modules/unpipe/package.json +59 -0
- data/lib/webpack_rails/node_modules/express/node_modules/finalhandler/package.json +81 -0
- data/lib/webpack_rails/node_modules/express/node_modules/fresh/HISTORY.md +38 -0
- data/lib/webpack_rails/node_modules/express/node_modules/fresh/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/fresh/README.md +58 -0
- data/lib/webpack_rails/node_modules/express/node_modules/fresh/index.js +57 -0
- data/lib/webpack_rails/node_modules/express/node_modules/fresh/package.json +87 -0
- data/lib/webpack_rails/node_modules/express/node_modules/merge-descriptors/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/merge-descriptors/README.md +34 -0
- data/lib/webpack_rails/node_modules/express/node_modules/merge-descriptors/index.js +57 -0
- data/lib/webpack_rails/node_modules/express/node_modules/merge-descriptors/package.json +125 -0
- data/lib/webpack_rails/node_modules/express/node_modules/methods/HISTORY.md +24 -0
- data/lib/webpack_rails/node_modules/express/node_modules/methods/LICENSE +23 -0
- data/lib/webpack_rails/node_modules/express/node_modules/methods/README.md +41 -0
- data/lib/webpack_rails/node_modules/express/node_modules/methods/index.js +42 -0
- data/lib/webpack_rails/node_modules/express/node_modules/methods/package.json +88 -0
- data/lib/webpack_rails/node_modules/express/node_modules/on-finished/HISTORY.md +88 -0
- data/lib/webpack_rails/node_modules/express/node_modules/on-finished/LICENSE +23 -0
- data/lib/webpack_rails/node_modules/express/node_modules/on-finished/README.md +154 -0
- data/lib/webpack_rails/node_modules/express/node_modules/on-finished/index.js +196 -0
- data/lib/webpack_rails/node_modules/express/node_modules/on-finished/node_modules/ee-first/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/on-finished/node_modules/ee-first/README.md +80 -0
- data/lib/webpack_rails/node_modules/express/node_modules/on-finished/node_modules/ee-first/index.js +95 -0
- data/lib/webpack_rails/node_modules/express/node_modules/on-finished/node_modules/ee-first/package.json +64 -0
- data/lib/webpack_rails/node_modules/express/node_modules/on-finished/package.json +71 -0
- data/lib/webpack_rails/node_modules/express/node_modules/parseurl/HISTORY.md +42 -0
- data/lib/webpack_rails/node_modules/express/node_modules/parseurl/LICENSE +24 -0
- data/lib/webpack_rails/node_modules/express/node_modules/parseurl/README.md +107 -0
- data/lib/webpack_rails/node_modules/express/node_modules/parseurl/index.js +136 -0
- data/lib/webpack_rails/node_modules/express/node_modules/parseurl/package.json +80 -0
- data/lib/webpack_rails/node_modules/express/node_modules/path-to-regexp/History.md +36 -0
- data/lib/webpack_rails/node_modules/express/node_modules/path-to-regexp/LICENSE +21 -0
- data/lib/webpack_rails/node_modules/express/node_modules/path-to-regexp/Readme.md +35 -0
- data/lib/webpack_rails/node_modules/express/node_modules/path-to-regexp/index.js +129 -0
- data/lib/webpack_rails/node_modules/express/node_modules/path-to-regexp/package.json +184 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/HISTORY.md +66 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/README.md +137 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/index.js +345 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/HISTORY.md +4 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/README.md +53 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/index.js +35 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/package.json +65 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/Cakefile +18 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/LICENSE +19 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/README.md +161 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/ipaddr.min.js +1 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/lib/ipaddr.js +439 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/package.json +60 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/src/ipaddr.coffee +374 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/test/ipaddr.test.coffee +262 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/package.json +90 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/CHANGELOG.md +88 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/CONTRIBUTING.md +1 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/LICENSE +28 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/README.md +317 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/bower.json +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/lib/index.js +15 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/lib/parse.js +186 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/lib/stringify.js +121 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/lib/utils.js +190 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/package.json +56 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/test/parse.js +478 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/test/stringify.js +259 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/test/utils.js +28 -0
- data/lib/webpack_rails/node_modules/express/node_modules/range-parser/HISTORY.md +35 -0
- data/lib/webpack_rails/node_modules/express/node_modules/range-parser/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/range-parser/README.md +48 -0
- data/lib/webpack_rails/node_modules/express/node_modules/range-parser/index.js +49 -0
- data/lib/webpack_rails/node_modules/express/node_modules/range-parser/package.json +76 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/HISTORY.md +295 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/LICENSE +23 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/README.md +195 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/index.js +820 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/destroy/README.md +38 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/destroy/index.js +36 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/destroy/package.json +67 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/http-errors/HISTORY.md +76 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/http-errors/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/http-errors/README.md +63 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/http-errors/index.js +120 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/LICENSE +16 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/README.md +42 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/inherits.js +1 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/inherits_browser.js +23 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/package.json +50 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/test.js +25 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/http-errors/package.json +85 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/mime/LICENSE +19 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/mime/README.md +90 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/mime/build/build.js +11 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/mime/build/test.js +57 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/mime/cli.js +8 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/mime/mime.js +108 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/mime/package.json +73 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/mime/types.json +1 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/ms/History.md +66 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/ms/LICENSE +20 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/ms/README.md +35 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/ms/index.js +125 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/ms/package.json +47 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/statuses/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/statuses/README.md +114 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/statuses/codes.json +64 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/statuses/index.js +60 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/statuses/package.json +84 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/package.json +89 -0
- data/lib/webpack_rails/node_modules/express/node_modules/serve-static/HISTORY.md +284 -0
- data/lib/webpack_rails/node_modules/express/node_modules/serve-static/LICENSE +25 -0
- data/lib/webpack_rails/node_modules/express/node_modules/serve-static/README.md +235 -0
- data/lib/webpack_rails/node_modules/express/node_modules/serve-static/index.js +187 -0
- data/lib/webpack_rails/node_modules/express/node_modules/serve-static/package.json +83 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/HISTORY.md +180 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/LICENSE +23 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/README.md +132 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/index.js +262 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/media-typer/HISTORY.md +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/media-typer/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/media-typer/README.md +81 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/media-typer/index.js +270 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/media-typer/package.json +58 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/mime-types/HISTORY.md +171 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/mime-types/LICENSE +23 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/mime-types/README.md +103 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/mime-types/index.js +188 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/HISTORY.md +274 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/README.md +82 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/db.json +6474 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/index.js +11 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/package.json +94 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/mime-types/package.json +84 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/package.json +93 -0
- data/lib/webpack_rails/node_modules/express/node_modules/utils-merge/LICENSE +20 -0
- data/lib/webpack_rails/node_modules/express/node_modules/utils-merge/README.md +34 -0
- data/lib/webpack_rails/node_modules/express/node_modules/utils-merge/index.js +23 -0
- data/lib/webpack_rails/node_modules/express/node_modules/utils-merge/package.json +58 -0
- data/lib/webpack_rails/node_modules/express/node_modules/vary/HISTORY.md +23 -0
- data/lib/webpack_rails/node_modules/express/node_modules/vary/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/vary/README.md +91 -0
- data/lib/webpack_rails/node_modules/express/node_modules/vary/index.js +117 -0
- data/lib/webpack_rails/node_modules/express/node_modules/vary/package.json +72 -0
- data/lib/webpack_rails/node_modules/express/package.json +167 -0
- data/lib/webpack_rails/node_modules/is-array/History.md +11 -0
- data/lib/webpack_rails/node_modules/is-array/Makefile +11 -0
- data/lib/webpack_rails/node_modules/is-array/Readme.md +27 -0
- data/lib/webpack_rails/node_modules/is-array/component.json +13 -0
- data/lib/webpack_rails/node_modules/is-array/index.js +33 -0
- data/lib/webpack_rails/node_modules/is-array/package.json +41 -0
- data/lib/webpack_rails/node_modules/is-array/test/test.html +46 -0
- data/lib/webpack_rails/node_modules/is-object/LICENSE +19 -0
- data/lib/webpack_rails/node_modules/is-object/README.md +55 -0
- data/lib/webpack_rails/node_modules/is-object/index.js +5 -0
- data/lib/webpack_rails/node_modules/is-object/package.json +91 -0
- data/lib/webpack_rails/node_modules/is-object/test/index.js +23 -0
- data/lib/webpack_rails/node_modules/is-string/CHANGELOG.md +19 -0
- data/lib/webpack_rails/node_modules/is-string/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/is-string/Makefile +61 -0
- data/lib/webpack_rails/node_modules/is-string/README.md +57 -0
- data/lib/webpack_rails/node_modules/is-string/index.js +20 -0
- data/lib/webpack_rails/node_modules/is-string/package.json +93 -0
- data/lib/webpack_rails/node_modules/is-string/test.js +36 -0
- data/lib/webpack_rails/node_modules/js-string-escape/CHANGELOG.md +9 -0
- data/lib/webpack_rails/node_modules/js-string-escape/LICENSE +21 -0
- data/lib/webpack_rails/node_modules/js-string-escape/README.md +44 -0
- data/lib/webpack_rails/node_modules/js-string-escape/index.js +22 -0
- data/lib/webpack_rails/node_modules/js-string-escape/package.json +63 -0
- data/lib/webpack_rails/node_modules/js-string-escape/test/test.js +43 -0
- data/lib/webpack_rails/node_modules/strip-ansi/index.js +6 -0
- data/lib/webpack_rails/node_modules/strip-ansi/license +21 -0
- data/lib/webpack_rails/node_modules/strip-ansi/node_modules/ansi-regex/index.js +4 -0
- data/lib/webpack_rails/node_modules/strip-ansi/node_modules/ansi-regex/license +21 -0
- data/lib/webpack_rails/node_modules/strip-ansi/node_modules/ansi-regex/package.json +86 -0
- data/lib/webpack_rails/node_modules/strip-ansi/node_modules/ansi-regex/readme.md +31 -0
- data/lib/webpack_rails/node_modules/strip-ansi/package.json +85 -0
- data/lib/webpack_rails/node_modules/strip-ansi/readme.md +33 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/README.md +109 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/client-overlay.js +35 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/client.js +131 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/example/README.md +15 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/example/client.js +30 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/example/index.html +18 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/example/package.json +14 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/example/server.js +41 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/example/webpack.config.js +22 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/helpers.js +8 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/middleware.js +83 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/querystring/History.md +20 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/querystring/License.md +19 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/querystring/Readme.md +15 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/querystring/decode.js +80 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/querystring/encode.js +64 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/querystring/index.js +4 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/querystring/package.json +96 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/querystring/test/common-index.js +3 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/querystring/test/index.js +210 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/querystring/test/tap-index.js +3 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/strip-ansi/cli.js +47 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/strip-ansi/index.js +6 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/strip-ansi/node_modules/ansi-regex/index.js +4 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/strip-ansi/node_modules/ansi-regex/license +21 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/strip-ansi/node_modules/ansi-regex/package.json +86 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/strip-ansi/node_modules/ansi-regex/readme.md +33 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/strip-ansi/package.json +89 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/strip-ansi/readme.md +43 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/package.json +58 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/process-update.js +105 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/test/client-test.js +81 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/test/helpers-test.js +22 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/test/middleware-test.js +188 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/test/mocha.opts +1 -0
- data/lib/webpack_rails/node_modules/xtend/LICENCE +19 -0
- data/lib/webpack_rails/node_modules/xtend/Makefile +4 -0
- data/lib/webpack_rails/node_modules/xtend/README.md +32 -0
- data/lib/webpack_rails/node_modules/xtend/immutable.js +17 -0
- data/lib/webpack_rails/node_modules/xtend/mutable.js +15 -0
- data/lib/webpack_rails/node_modules/xtend/package.json +88 -0
- data/lib/webpack_rails/node_modules/xtend/test.js +63 -0
- data/lib/webpack_rails/package.json +22 -0
- data/lib/webpack_rails/processor.rb +28 -9
- data/lib/webpack_rails/require_directive_processor.rb +51 -0
- data/lib/webpack_rails/sprockets_environment.rb +45 -0
- data/lib/webpack_rails/task.rb +51 -22
- data/lib/webpack_rails/webpack-task-dev-server.js +122 -0
- data/lib/webpack_rails/{webpack-task.js → webpack-task-watch.js} +0 -0
- data/lib/webpack_rails/webpack.rake +5 -5
- data/lib/webpack_rails.rb +1 -3
- metadata +346 -5
- data/lib/webpack_rails/sprockets_base_webpack.rb +0 -14
- data/lib/webpack_rails/sprockets_index_webpack.rb +0 -15
@@ -0,0 +1,652 @@
|
|
1
|
+
(function () {
|
2
|
+
/*global describe, it*/
|
3
|
+
|
4
|
+
'use strict';
|
5
|
+
|
6
|
+
var should = require('should'),
|
7
|
+
cors = require('../lib');
|
8
|
+
|
9
|
+
var fakeRequest = function (headers) {
|
10
|
+
return {
|
11
|
+
headers: headers || {
|
12
|
+
'origin': 'request.com',
|
13
|
+
'access-control-request-headers': 'requestedHeader1,requestedHeader2'
|
14
|
+
},
|
15
|
+
pause: function () {
|
16
|
+
// do nothing
|
17
|
+
return;
|
18
|
+
},
|
19
|
+
resume: function () {
|
20
|
+
// do nothing
|
21
|
+
return;
|
22
|
+
}
|
23
|
+
};
|
24
|
+
},
|
25
|
+
fakeResponse = function () {
|
26
|
+
var headers = {};
|
27
|
+
return {
|
28
|
+
allHeaders: function () {
|
29
|
+
return headers;
|
30
|
+
},
|
31
|
+
getHeader: function (key) {
|
32
|
+
return headers[key];
|
33
|
+
},
|
34
|
+
setHeader: function (key, value) {
|
35
|
+
headers[key] = value;
|
36
|
+
return;
|
37
|
+
},
|
38
|
+
get: function (key) {
|
39
|
+
return headers[key];
|
40
|
+
}
|
41
|
+
};
|
42
|
+
};
|
43
|
+
|
44
|
+
describe('cors', function () {
|
45
|
+
it('passes control to next middleware', function (done) {
|
46
|
+
// arrange
|
47
|
+
var req, res, next;
|
48
|
+
req = fakeRequest();
|
49
|
+
res = fakeResponse();
|
50
|
+
next = function () {
|
51
|
+
done();
|
52
|
+
};
|
53
|
+
|
54
|
+
// act
|
55
|
+
cors()(req, res, next);
|
56
|
+
});
|
57
|
+
|
58
|
+
it('shortcircuits preflight requests', function (done) {
|
59
|
+
// arrange
|
60
|
+
var req, res, next;
|
61
|
+
req = fakeRequest();
|
62
|
+
req.method = 'OPTIONS';
|
63
|
+
res = fakeResponse();
|
64
|
+
res.end = function () {
|
65
|
+
// assert
|
66
|
+
res.statusCode.should.equal(204);
|
67
|
+
done();
|
68
|
+
};
|
69
|
+
next = function () {
|
70
|
+
// assert
|
71
|
+
done('should not be called');
|
72
|
+
};
|
73
|
+
|
74
|
+
// act
|
75
|
+
cors()(req, res, next);
|
76
|
+
});
|
77
|
+
|
78
|
+
it('doesn\'t shortcircuit preflight requests with preflightContinue option', function (done) {
|
79
|
+
// arrange
|
80
|
+
var req, res, next;
|
81
|
+
req = fakeRequest();
|
82
|
+
req.method = 'OPTIONS';
|
83
|
+
res = fakeResponse();
|
84
|
+
res.end = function () {
|
85
|
+
// assert
|
86
|
+
done('should not be called');
|
87
|
+
};
|
88
|
+
next = function () {
|
89
|
+
// assert
|
90
|
+
done();
|
91
|
+
};
|
92
|
+
|
93
|
+
// act
|
94
|
+
cors({preflightContinue: true})(req, res, next);
|
95
|
+
});
|
96
|
+
|
97
|
+
it('normalizes method names', function (done) {
|
98
|
+
// arrange
|
99
|
+
var req, res, next;
|
100
|
+
req = fakeRequest();
|
101
|
+
req.method = 'options';
|
102
|
+
res = fakeResponse();
|
103
|
+
res.end = function () {
|
104
|
+
// assert
|
105
|
+
res.statusCode.should.equal(204);
|
106
|
+
done();
|
107
|
+
};
|
108
|
+
next = function () {
|
109
|
+
// assert
|
110
|
+
done('should not be called');
|
111
|
+
};
|
112
|
+
|
113
|
+
// act
|
114
|
+
cors()(req, res, next);
|
115
|
+
});
|
116
|
+
|
117
|
+
it('no options enables default CORS to all origins', function (done) {
|
118
|
+
// arrange
|
119
|
+
var req, res, next;
|
120
|
+
req = fakeRequest();
|
121
|
+
res = fakeResponse();
|
122
|
+
next = function () {
|
123
|
+
// assert
|
124
|
+
res.getHeader('Access-Control-Allow-Origin').should.equal('*');
|
125
|
+
should.not.exist(res.getHeader('Access-Control-Allow-Methods'));
|
126
|
+
done();
|
127
|
+
};
|
128
|
+
|
129
|
+
// act
|
130
|
+
cors()(req, res, next);
|
131
|
+
});
|
132
|
+
|
133
|
+
it('OPTION call with no options enables default CORS to all origins and methods', function (done) {
|
134
|
+
// arrange
|
135
|
+
var req, res, next;
|
136
|
+
req = fakeRequest();
|
137
|
+
req.method = 'OPTIONS';
|
138
|
+
res = fakeResponse();
|
139
|
+
res.end = function () {
|
140
|
+
// assert
|
141
|
+
res.statusCode.should.equal(204);
|
142
|
+
done();
|
143
|
+
};
|
144
|
+
next = function () {
|
145
|
+
// assert
|
146
|
+
res.getHeader('Access-Control-Allow-Origin').should.equal('*');
|
147
|
+
res.getHeader('Access-Control-Allow-Methods').should.equal('GET,PUT,PATCH,POST,DELETE');
|
148
|
+
done();
|
149
|
+
};
|
150
|
+
|
151
|
+
// act
|
152
|
+
cors()(req, res, next);
|
153
|
+
});
|
154
|
+
|
155
|
+
describe('passing static options', function () {
|
156
|
+
it('overrides defaults', function (done) {
|
157
|
+
// arrange
|
158
|
+
var req, res, next, options;
|
159
|
+
options = {
|
160
|
+
origin: 'example.com',
|
161
|
+
methods: ['FOO', 'bar'],
|
162
|
+
headers: ['FIZZ', 'buzz'],
|
163
|
+
credentials: true,
|
164
|
+
maxAge: 123
|
165
|
+
};
|
166
|
+
req = fakeRequest();
|
167
|
+
req.method = 'OPTIONS';
|
168
|
+
res = fakeResponse();
|
169
|
+
res.end = function () {
|
170
|
+
// assert
|
171
|
+
res.statusCode.should.equal(204);
|
172
|
+
done();
|
173
|
+
};
|
174
|
+
next = function () {
|
175
|
+
// assert
|
176
|
+
res.getHeader('Access-Control-Allow-Origin').should.equal('example.com');
|
177
|
+
res.getHeader('Access-Control-Allow-Methods').should.equal('FOO,bar');
|
178
|
+
res.getHeader('Access-Control-Allow-Headers').should.equal('FIZZ,buzz');
|
179
|
+
res.getHeader('Access-Control-Allow-Credentials').should.equal('true');
|
180
|
+
res.getHeader('Access-Control-Allow-Max-Age').should.equal('123');
|
181
|
+
done();
|
182
|
+
};
|
183
|
+
|
184
|
+
// act
|
185
|
+
cors(options)(req, res, next);
|
186
|
+
});
|
187
|
+
|
188
|
+
it('matches request origin against regexp', function(done) {
|
189
|
+
var req = fakeRequest();
|
190
|
+
var res = fakeResponse();
|
191
|
+
var options = { origin: /^(.+\.)?request.com$/ };
|
192
|
+
cors(options)(req, res, function(err) {
|
193
|
+
should.not.exist(err);
|
194
|
+
res.getHeader('Access-Control-Allow-Origin').should.equal(req.headers.origin);
|
195
|
+
should.exist(res.getHeader('Vary'));
|
196
|
+
res.getHeader('Vary').should.equal('Origin');
|
197
|
+
return done();
|
198
|
+
});
|
199
|
+
});
|
200
|
+
|
201
|
+
it('matches request origin against array of origin checks', function(done) {
|
202
|
+
var req = fakeRequest();
|
203
|
+
var res = fakeResponse();
|
204
|
+
var options = { origin: [ /foo\.com$/, 'request.com' ] };
|
205
|
+
cors(options)(req, res, function(err) {
|
206
|
+
should.not.exist(err);
|
207
|
+
res.getHeader('Access-Control-Allow-Origin').should.equal(req.headers.origin);
|
208
|
+
should.exist(res.getHeader('Vary'));
|
209
|
+
res.getHeader('Vary').should.equal('Origin');
|
210
|
+
return done();
|
211
|
+
});
|
212
|
+
});
|
213
|
+
|
214
|
+
it('doesn\'t match request origin against array of invalid origin checks', function(done) {
|
215
|
+
var req = fakeRequest();
|
216
|
+
var res = fakeResponse();
|
217
|
+
var options = { origin: [ /foo\.com$/, 'bar.com' ] };
|
218
|
+
cors(options)(req, res, function(err) {
|
219
|
+
should.not.exist(err);
|
220
|
+
should.not.exist(res.getHeader('Access-Control-Allow-Origin'));
|
221
|
+
should.not.exist(res.getHeader('Vary'));
|
222
|
+
return done();
|
223
|
+
});
|
224
|
+
});
|
225
|
+
|
226
|
+
it('origin of false disables cors', function (done) {
|
227
|
+
// arrange
|
228
|
+
var req, res, next, options;
|
229
|
+
options = {
|
230
|
+
origin: false,
|
231
|
+
methods: ['FOO', 'bar'],
|
232
|
+
headers: ['FIZZ', 'buzz'],
|
233
|
+
credentials: true,
|
234
|
+
maxAge: 123
|
235
|
+
};
|
236
|
+
req = fakeRequest();
|
237
|
+
res = fakeResponse();
|
238
|
+
next = function () {
|
239
|
+
// assert
|
240
|
+
should.not.exist(res.getHeader('Access-Control-Allow-Origin'));
|
241
|
+
should.not.exist(res.getHeader('Access-Control-Allow-Methods'));
|
242
|
+
should.not.exist(res.getHeader('Access-Control-Allow-Headers'));
|
243
|
+
should.not.exist(res.getHeader('Access-Control-Allow-Credentials'));
|
244
|
+
should.not.exist(res.getHeader('Access-Control-Allow-Max-Age'));
|
245
|
+
done();
|
246
|
+
};
|
247
|
+
|
248
|
+
// act
|
249
|
+
cors(options)(req, res, next);
|
250
|
+
});
|
251
|
+
|
252
|
+
it('can override origin', function (done) {
|
253
|
+
// arrange
|
254
|
+
var req, res, next, options;
|
255
|
+
options = {
|
256
|
+
origin: 'example.com'
|
257
|
+
};
|
258
|
+
req = fakeRequest();
|
259
|
+
res = fakeResponse();
|
260
|
+
next = function () {
|
261
|
+
// assert
|
262
|
+
res.getHeader('Access-Control-Allow-Origin').should.equal('example.com');
|
263
|
+
done();
|
264
|
+
};
|
265
|
+
|
266
|
+
// act
|
267
|
+
cors(options)(req, res, next);
|
268
|
+
});
|
269
|
+
|
270
|
+
it('includes Vary header for specific origins', function (done) {
|
271
|
+
// arrange
|
272
|
+
var req, res, next, options;
|
273
|
+
options = {
|
274
|
+
origin: 'example.com'
|
275
|
+
};
|
276
|
+
req = fakeRequest();
|
277
|
+
res = fakeResponse();
|
278
|
+
next = function () {
|
279
|
+
// assert
|
280
|
+
should.exist(res.getHeader('Vary'));
|
281
|
+
res.getHeader('Vary').should.equal('Origin');
|
282
|
+
done();
|
283
|
+
};
|
284
|
+
|
285
|
+
// act
|
286
|
+
cors(options)(req, res, next);
|
287
|
+
});
|
288
|
+
|
289
|
+
it('appends to an existing Vary header', function (done) {
|
290
|
+
// arrange
|
291
|
+
var req, res, next, options;
|
292
|
+
options = {
|
293
|
+
origin: 'example.com'
|
294
|
+
};
|
295
|
+
req = fakeRequest();
|
296
|
+
res = fakeResponse();
|
297
|
+
res.setHeader('Vary', 'Foo');
|
298
|
+
next = function () {
|
299
|
+
// assert
|
300
|
+
res.getHeader('Vary').should.equal('Foo, Origin');
|
301
|
+
done();
|
302
|
+
};
|
303
|
+
|
304
|
+
// act
|
305
|
+
cors(options)(req, res, next);
|
306
|
+
});
|
307
|
+
|
308
|
+
it('origin defaults to *', function (done) {
|
309
|
+
// arrange
|
310
|
+
var req, res, next, options;
|
311
|
+
options = {
|
312
|
+
};
|
313
|
+
req = fakeRequest();
|
314
|
+
res = fakeResponse();
|
315
|
+
next = function () {
|
316
|
+
// assert
|
317
|
+
res.getHeader('Access-Control-Allow-Origin').should.equal('*');
|
318
|
+
done();
|
319
|
+
};
|
320
|
+
|
321
|
+
// act
|
322
|
+
cors(options)(req, res, next);
|
323
|
+
});
|
324
|
+
|
325
|
+
it('specifying true for origin reflects requesting origin', function (done) {
|
326
|
+
// arrange
|
327
|
+
var req, res, next, options;
|
328
|
+
options = {
|
329
|
+
origin: true
|
330
|
+
};
|
331
|
+
req = fakeRequest();
|
332
|
+
res = fakeResponse();
|
333
|
+
next = function () {
|
334
|
+
// assert
|
335
|
+
res.getHeader('Access-Control-Allow-Origin').should.equal('request.com');
|
336
|
+
done();
|
337
|
+
};
|
338
|
+
|
339
|
+
// act
|
340
|
+
cors(options)(req, res, next);
|
341
|
+
});
|
342
|
+
|
343
|
+
it('should allow origin when callback returns true', function (done) {
|
344
|
+
var req, res, next, options;
|
345
|
+
options = {
|
346
|
+
origin: function (sentOrigin, cb) {
|
347
|
+
sentOrigin.should.equal('request.com');
|
348
|
+
cb(null, true);
|
349
|
+
}
|
350
|
+
};
|
351
|
+
req = fakeRequest();
|
352
|
+
res = fakeResponse();
|
353
|
+
next = function () {
|
354
|
+
res.getHeader('Access-Control-Allow-Origin').should.equal('request.com');
|
355
|
+
done();
|
356
|
+
};
|
357
|
+
|
358
|
+
cors(options)(req, res, next);
|
359
|
+
});
|
360
|
+
|
361
|
+
it('should not allow origin when callback returns false', function (done) {
|
362
|
+
var req, res, next, options;
|
363
|
+
options = {
|
364
|
+
origin: function (sentOrigin, cb) {
|
365
|
+
sentOrigin.should.equal('request.com');
|
366
|
+
cb(null, false);
|
367
|
+
}
|
368
|
+
};
|
369
|
+
req = fakeRequest();
|
370
|
+
res = fakeResponse();
|
371
|
+
next = function () {
|
372
|
+
should.not.exist(res.getHeader('Access-Control-Allow-Origin'));
|
373
|
+
should.not.exist(res.getHeader('Access-Control-Allow-Methods'));
|
374
|
+
should.not.exist(res.getHeader('Access-Control-Allow-Headers'));
|
375
|
+
should.not.exist(res.getHeader('Access-Control-Allow-Credentials'));
|
376
|
+
should.not.exist(res.getHeader('Access-Control-Allow-Max-Age'));
|
377
|
+
done();
|
378
|
+
};
|
379
|
+
|
380
|
+
cors(options)(req, res, next);
|
381
|
+
});
|
382
|
+
|
383
|
+
it('should not override options.origin callback', function (done) {
|
384
|
+
var req, res, next, options;
|
385
|
+
options = {
|
386
|
+
origin: function (sentOrigin, cb) {
|
387
|
+
var isValid = sentOrigin === 'request.com';
|
388
|
+
cb(null, isValid);
|
389
|
+
}
|
390
|
+
};
|
391
|
+
|
392
|
+
req = fakeRequest();
|
393
|
+
res = fakeResponse();
|
394
|
+
next = function () {
|
395
|
+
res.getHeader('Access-Control-Allow-Origin').should.equal('request.com');
|
396
|
+
};
|
397
|
+
|
398
|
+
cors(options)(req, res, next);
|
399
|
+
|
400
|
+
req = fakeRequest({
|
401
|
+
'origin': 'invalid-request.com'
|
402
|
+
});
|
403
|
+
res = fakeResponse();
|
404
|
+
|
405
|
+
next = function () {
|
406
|
+
should.not.exist(res.getHeader('Access-Control-Allow-Origin'));
|
407
|
+
should.not.exist(res.getHeader('Access-Control-Allow-Methods'));
|
408
|
+
should.not.exist(res.getHeader('Access-Control-Allow-Headers'));
|
409
|
+
should.not.exist(res.getHeader('Access-Control-Allow-Credentials'));
|
410
|
+
should.not.exist(res.getHeader('Access-Control-Allow-Max-Age'));
|
411
|
+
done();
|
412
|
+
};
|
413
|
+
|
414
|
+
cors(options)(req, res, next);
|
415
|
+
});
|
416
|
+
|
417
|
+
|
418
|
+
it('can override methods', function (done) {
|
419
|
+
// arrange
|
420
|
+
var req, res, next, options;
|
421
|
+
options = {
|
422
|
+
methods: ['method1', 'method2']
|
423
|
+
};
|
424
|
+
req = fakeRequest();
|
425
|
+
req.method = 'OPTIONS';
|
426
|
+
res = fakeResponse();
|
427
|
+
res.end = function () {
|
428
|
+
// assert
|
429
|
+
res.statusCode.should.equal(204);
|
430
|
+
done();
|
431
|
+
};
|
432
|
+
next = function () {
|
433
|
+
// assert
|
434
|
+
res.getHeader('Access-Control-Allow-Methods').should.equal('method1,method2');
|
435
|
+
done();
|
436
|
+
};
|
437
|
+
|
438
|
+
// act
|
439
|
+
cors(options)(req, res, next);
|
440
|
+
});
|
441
|
+
|
442
|
+
it('methods defaults to GET, PUT, PATCH, POST, DELETE', function (done) {
|
443
|
+
// arrange
|
444
|
+
var req, res, next, options;
|
445
|
+
options = {
|
446
|
+
};
|
447
|
+
req = fakeRequest();
|
448
|
+
req.method = 'OPTIONS';
|
449
|
+
res = fakeResponse();
|
450
|
+
res.end = function () {
|
451
|
+
// assert
|
452
|
+
res.statusCode.should.equal(204);
|
453
|
+
done();
|
454
|
+
};
|
455
|
+
next = function () {
|
456
|
+
// assert
|
457
|
+
res.getHeader('Access-Control-Allow-Methods').should.equal('GET,PUT,PATCH,POST,DELETE');
|
458
|
+
done();
|
459
|
+
};
|
460
|
+
|
461
|
+
// act
|
462
|
+
cors(options)(req, res, next);
|
463
|
+
});
|
464
|
+
|
465
|
+
it('can specify allowed headers', function (done) {
|
466
|
+
// arrange
|
467
|
+
var req, res, options;
|
468
|
+
options = {
|
469
|
+
allowedHeaders: ['header1', 'header2']
|
470
|
+
};
|
471
|
+
req = fakeRequest();
|
472
|
+
req.method = 'OPTIONS';
|
473
|
+
res = fakeResponse();
|
474
|
+
res.end = function () {
|
475
|
+
// assert
|
476
|
+
res.getHeader('Access-Control-Allow-Headers').should.equal('header1,header2');
|
477
|
+
done();
|
478
|
+
};
|
479
|
+
|
480
|
+
// act
|
481
|
+
cors(options)(req, res, null);
|
482
|
+
});
|
483
|
+
|
484
|
+
it('specifying an empty list or string of allowed headers will result in no response header for allowed headers', function (done) {
|
485
|
+
// arrange
|
486
|
+
var req, res, next, options;
|
487
|
+
options = {
|
488
|
+
allowedHeaders: []
|
489
|
+
};
|
490
|
+
req = fakeRequest();
|
491
|
+
res = fakeResponse();
|
492
|
+
next = function () {
|
493
|
+
// assert
|
494
|
+
should.not.exist(res.getHeader('Access-Control-Allow-Headers'));
|
495
|
+
done();
|
496
|
+
};
|
497
|
+
|
498
|
+
// act
|
499
|
+
cors(options)(req, res, next);
|
500
|
+
});
|
501
|
+
|
502
|
+
it('if no allowed headers are specified, defaults to requested allowed headers', function (done) {
|
503
|
+
// arrange
|
504
|
+
var req, res, options;
|
505
|
+
options = {
|
506
|
+
};
|
507
|
+
req = fakeRequest();
|
508
|
+
req.method = 'OPTIONS';
|
509
|
+
res = fakeResponse();
|
510
|
+
res.end = function () {
|
511
|
+
// assert
|
512
|
+
res.getHeader('Access-Control-Allow-Headers').should.equal('requestedHeader1,requestedHeader2');
|
513
|
+
done();
|
514
|
+
};
|
515
|
+
|
516
|
+
// act
|
517
|
+
cors(options)(req, res, null);
|
518
|
+
});
|
519
|
+
|
520
|
+
it('can specify exposed headers', function (done) {
|
521
|
+
// arrange
|
522
|
+
var req, res, options, next;
|
523
|
+
options = {
|
524
|
+
exposedHeaders: ['custom-header1', 'custom-header2']
|
525
|
+
};
|
526
|
+
req = fakeRequest();
|
527
|
+
res = fakeResponse();
|
528
|
+
next = function () {
|
529
|
+
// assert
|
530
|
+
res.getHeader('Access-Control-Expose-Headers').should.equal('custom-header1,custom-header2');
|
531
|
+
done();
|
532
|
+
};
|
533
|
+
|
534
|
+
// act
|
535
|
+
cors(options)(req, res, next);
|
536
|
+
});
|
537
|
+
|
538
|
+
it('includes credentials if explicitly enabled', function (done) {
|
539
|
+
// arrange
|
540
|
+
var req, res, options;
|
541
|
+
options = {
|
542
|
+
credentials: true
|
543
|
+
};
|
544
|
+
req = fakeRequest();
|
545
|
+
req.method = 'OPTIONS';
|
546
|
+
res = fakeResponse();
|
547
|
+
res.end = function () {
|
548
|
+
// assert
|
549
|
+
res.getHeader('Access-Control-Allow-Credentials').should.equal('true');
|
550
|
+
done();
|
551
|
+
};
|
552
|
+
|
553
|
+
// act
|
554
|
+
cors(options)(req, res, null);
|
555
|
+
});
|
556
|
+
|
557
|
+
it('does not includes credentials unless explicitly enabled', function (done) {
|
558
|
+
// arrange
|
559
|
+
var req, res, next, options;
|
560
|
+
options = {
|
561
|
+
};
|
562
|
+
req = fakeRequest();
|
563
|
+
res = fakeResponse();
|
564
|
+
next = function () {
|
565
|
+
// assert
|
566
|
+
should.not.exist(res.getHeader('Access-Control-Allow-Credentials'));
|
567
|
+
done();
|
568
|
+
};
|
569
|
+
|
570
|
+
// act
|
571
|
+
cors(options)(req, res, next);
|
572
|
+
});
|
573
|
+
|
574
|
+
it('includes maxAge when specified', function (done) {
|
575
|
+
// arrange
|
576
|
+
var req, res, options;
|
577
|
+
options = {
|
578
|
+
maxAge: 456
|
579
|
+
};
|
580
|
+
req = fakeRequest();
|
581
|
+
req.method = 'OPTIONS';
|
582
|
+
res = fakeResponse();
|
583
|
+
res.end = function () {
|
584
|
+
// assert
|
585
|
+
res.getHeader('Access-Control-Max-Age').should.equal('456');
|
586
|
+
done();
|
587
|
+
};
|
588
|
+
|
589
|
+
// act
|
590
|
+
cors(options)(req, res, null);
|
591
|
+
});
|
592
|
+
|
593
|
+
it('does not includes maxAge unless specified', function (done) {
|
594
|
+
// arrange
|
595
|
+
var req, res, next, options;
|
596
|
+
options = {
|
597
|
+
};
|
598
|
+
req = fakeRequest();
|
599
|
+
res = fakeResponse();
|
600
|
+
next = function () {
|
601
|
+
// assert
|
602
|
+
should.not.exist(res.getHeader('Access-Control-Allow-Max-Age'));
|
603
|
+
done();
|
604
|
+
};
|
605
|
+
|
606
|
+
// act
|
607
|
+
cors(options)(req, res, next);
|
608
|
+
});
|
609
|
+
});
|
610
|
+
|
611
|
+
describe('passing a function to build options', function () {
|
612
|
+
it('handles options specified via callback', function (done) {
|
613
|
+
// arrange
|
614
|
+
var req, res, next, delegate;
|
615
|
+
delegate = function (req2, cb) {
|
616
|
+
cb(null, {
|
617
|
+
origin: 'delegate.com'
|
618
|
+
});
|
619
|
+
};
|
620
|
+
req = fakeRequest();
|
621
|
+
res = fakeResponse();
|
622
|
+
next = function () {
|
623
|
+
// assert
|
624
|
+
res.getHeader('Access-Control-Allow-Origin').should.equal('delegate.com');
|
625
|
+
done();
|
626
|
+
};
|
627
|
+
|
628
|
+
// act
|
629
|
+
cors(delegate)(req, res, next);
|
630
|
+
});
|
631
|
+
|
632
|
+
it('handles error specified via callback', function (done) {
|
633
|
+
// arrange
|
634
|
+
var req, res, next, delegate;
|
635
|
+
delegate = function (req2, cb) {
|
636
|
+
cb('some error');
|
637
|
+
};
|
638
|
+
req = fakeRequest();
|
639
|
+
res = fakeResponse();
|
640
|
+
next = function (err) {
|
641
|
+
// assert
|
642
|
+
err.should.equal('some error');
|
643
|
+
done();
|
644
|
+
};
|
645
|
+
|
646
|
+
// act
|
647
|
+
cors(delegate)(req, res, next);
|
648
|
+
});
|
649
|
+
});
|
650
|
+
});
|
651
|
+
|
652
|
+
}());
|