Showing
471 changed files
with
3902 additions
and
141 deletions
... | @@ -9,6 +9,10 @@ var cheerio = require('cheerio'); | ... | @@ -9,6 +9,10 @@ var cheerio = require('cheerio'); |
9 | var request = require('request'); | 9 | var request = require('request'); |
10 | var index = require('./routes/index'); | 10 | var index = require('./routes/index'); |
11 | var index2 = require('./routes/index2'); | 11 | var index2 = require('./routes/index2'); |
12 | +var adduser = require('./routes/adduser'); | ||
13 | + | ||
14 | +var addtodb = require('./routes/adduser'); | ||
15 | + | ||
12 | var login = require('./routes/login'); | 16 | var login = require('./routes/login'); |
13 | var users = require('./routes/users'); | 17 | var users = require('./routes/users'); |
14 | var mytoons = require('./routes/mytoons'); | 18 | var mytoons = require('./routes/mytoons'); |
... | @@ -67,9 +71,13 @@ app.use('/users', users); | ... | @@ -67,9 +71,13 @@ app.use('/users', users); |
67 | app.use('/mytoons', mytoons); | 71 | app.use('/mytoons', mytoons); |
68 | app.use('/setting', setting); | 72 | app.use('/setting', setting); |
69 | app.use('/yourtoons', yourtoons); | 73 | app.use('/yourtoons', yourtoons); |
74 | +app.use('/adduser', adduser); | ||
75 | +// app.use('/addtodb', addtodb); | ||
70 | //app.use(express.static('views')); | 76 | //app.use(express.static('views')); |
71 | 77 | ||
72 | -// catch 404 and forward to error handler | 78 | + |
79 | + | ||
80 | +//catch 404 and forward to error handler | ||
73 | app.use(function(req, res, next) { | 81 | app.use(function(req, res, next) { |
74 | var err = new Error('Not Found'); | 82 | var err = new Error('Not Found'); |
75 | err.status = 404; | 83 | err.status = 404; | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "@types/cheerio@0.22.14", | 4 | "@types/cheerio@0.22.14", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "@types/cheerio@0.22.14", | 8 | "_from": "@types/cheerio@0.22.14", |
... | @@ -27,7 +27,7 @@ | ... | @@ -27,7 +27,7 @@ |
27 | ], | 27 | ], |
28 | "_resolved": "https://registry.npmjs.org/@types/cheerio/-/cheerio-0.22.14.tgz", | 28 | "_resolved": "https://registry.npmjs.org/@types/cheerio/-/cheerio-0.22.14.tgz", |
29 | "_spec": "0.22.14", | 29 | "_spec": "0.22.14", |
30 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 30 | + "_where": "/Users/star/Desktop/YTMT", |
31 | "bugs": { | 31 | "bugs": { |
32 | "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues" | 32 | "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues" |
33 | }, | 33 | }, | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "@types/node@10.12.8", | 4 | "@types/node@10.12.8", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "@types/node@10.12.8", | 8 | "_from": "@types/node@10.12.8", |
... | @@ -28,7 +28,7 @@ | ... | @@ -28,7 +28,7 @@ |
28 | ], | 28 | ], |
29 | "_resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.8.tgz", | 29 | "_resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.8.tgz", |
30 | "_spec": "10.12.8", | 30 | "_spec": "10.12.8", |
31 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 31 | + "_where": "/Users/star/Desktop/YTMT", |
32 | "bugs": { | 32 | "bugs": { |
33 | "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues" | 33 | "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues" |
34 | }, | 34 | }, | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "accepts@1.3.5", | 4 | "accepts@1.3.5", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "accepts@1.3.5", | 8 | "_from": "accepts@1.3.5", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", | 27 | "_resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", |
28 | "_spec": "1.3.5", | 28 | "_spec": "1.3.5", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "bugs": { | 30 | "bugs": { |
31 | "url": "https://github.com/jshttp/accepts/issues" | 31 | "url": "https://github.com/jshttp/accepts/issues" |
32 | }, | 32 | }, | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "agent-base@4.3.0", | 4 | "agent-base@4.3.0", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "agent-base@4.3.0", | 8 | "_from": "agent-base@4.3.0", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", | 27 | "_resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", |
28 | "_spec": "4.3.0", | 28 | "_spec": "4.3.0", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "Nathan Rajlich", | 31 | "name": "Nathan Rajlich", |
32 | "email": "nathan@tootallnate.net", | 32 | "email": "nathan@tootallnate.net", | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "ajv@6.5.5", | 4 | "ajv@6.5.5", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "ajv@6.5.5", | 8 | "_from": "ajv@6.5.5", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.5.tgz", | 27 | "_resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.5.tgz", |
28 | "_spec": "6.5.5", | 28 | "_spec": "6.5.5", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "Evgeny Poberezkin" | 31 | "name": "Evgeny Poberezkin" |
32 | }, | 32 | }, | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "ansi-regex@2.1.1", | 4 | "ansi-regex@2.1.1", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "ansi-regex@2.1.1", | 8 | "_from": "ansi-regex@2.1.1", |
... | @@ -27,7 +27,7 @@ | ... | @@ -27,7 +27,7 @@ |
27 | ], | 27 | ], |
28 | "_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", | 28 | "_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", |
29 | "_spec": "2.1.1", | 29 | "_spec": "2.1.1", |
30 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 30 | + "_where": "/Users/star/Desktop/YTMT", |
31 | "author": { | 31 | "author": { |
32 | "name": "Sindre Sorhus", | 32 | "name": "Sindre Sorhus", |
33 | "email": "sindresorhus@gmail.com", | 33 | "email": "sindresorhus@gmail.com", | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "ansi-styles@2.2.1", | 4 | "ansi-styles@2.2.1", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "ansi-styles@2.2.1", | 8 | "_from": "ansi-styles@2.2.1", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", | 27 | "_resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", |
28 | "_spec": "2.2.1", | 28 | "_spec": "2.2.1", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "Sindre Sorhus", | 31 | "name": "Sindre Sorhus", |
32 | "email": "sindresorhus@gmail.com", | 32 | "email": "sindresorhus@gmail.com", | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "array-flatten@1.1.1", | 4 | "array-flatten@1.1.1", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "array-flatten@1.1.1", | 8 | "_from": "array-flatten@1.1.1", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", | 27 | "_resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", |
28 | "_spec": "1.1.1", | 28 | "_spec": "1.1.1", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "Blake Embrey", | 31 | "name": "Blake Embrey", |
32 | "email": "hello@blakeembrey.com", | 32 | "email": "hello@blakeembrey.com", | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "asn1@0.2.4", | 4 | "asn1@0.2.4", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "asn1@0.2.4", | 8 | "_from": "asn1@0.2.4", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", | 27 | "_resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", |
28 | "_spec": "0.2.4", | 28 | "_spec": "0.2.4", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "Joyent", | 31 | "name": "Joyent", |
32 | "url": "joyent.com" | 32 | "url": "joyent.com" | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "assert-plus@0.2.0", | 4 | "assert-plus@0.2.0", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "assert-plus@0.2.0", | 8 | "_from": "assert-plus@0.2.0", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", | 27 | "_resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", |
28 | "_spec": "0.2.0", | 28 | "_spec": "0.2.0", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "Mark Cavage", | 31 | "name": "Mark Cavage", |
32 | "email": "mcavage@gmail.com" | 32 | "email": "mcavage@gmail.com" | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "async-limiter@1.0.1", | 4 | "async-limiter@1.0.1", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "async-limiter@1.0.1", | 8 | "_from": "async-limiter@1.0.1", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", | 27 | "_resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", |
28 | "_spec": "1.0.1", | 28 | "_spec": "1.0.1", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "Samuel Reed" | 31 | "name": "Samuel Reed" |
32 | }, | 32 | }, | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "async@2.6.1", | 4 | "async@2.6.1", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "async@2.6.1", | 8 | "_from": "async@2.6.1", |
... | @@ -27,7 +27,7 @@ | ... | @@ -27,7 +27,7 @@ |
27 | ], | 27 | ], |
28 | "_resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz", | 28 | "_resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz", |
29 | "_spec": "2.6.1", | 29 | "_spec": "2.6.1", |
30 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 30 | + "_where": "/Users/star/Desktop/YTMT", |
31 | "author": { | 31 | "author": { |
32 | "name": "Caolan McMahon" | 32 | "name": "Caolan McMahon" |
33 | }, | 33 | }, | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "asynckit@0.4.0", | 4 | "asynckit@0.4.0", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "asynckit@0.4.0", | 8 | "_from": "asynckit@0.4.0", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", | 27 | "_resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", |
28 | "_spec": "0.4.0", | 28 | "_spec": "0.4.0", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "Alex Indigo", | 31 | "name": "Alex Indigo", |
32 | "email": "iam@alexindigo.com" | 32 | "email": "iam@alexindigo.com" | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "aws-sign2@0.6.0", | 4 | "aws-sign2@0.6.0", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "aws-sign2@0.6.0", | 8 | "_from": "aws-sign2@0.6.0", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", | 27 | "_resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", |
28 | "_spec": "0.6.0", | 28 | "_spec": "0.6.0", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "Mikeal Rogers", | 31 | "name": "Mikeal Rogers", |
32 | "email": "mikeal.rogers@gmail.com", | 32 | "email": "mikeal.rogers@gmail.com", | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "aws4@1.8.0", | 4 | "aws4@1.8.0", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "aws4@1.8.0", | 8 | "_from": "aws4@1.8.0", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", | 27 | "_resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", |
28 | "_spec": "1.8.0", | 28 | "_spec": "1.8.0", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "Michael Hart", | 31 | "name": "Michael Hart", |
32 | "email": "michael.hart.au@gmail.com", | 32 | "email": "michael.hart.au@gmail.com", | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "balanced-match@1.0.0", | 4 | "balanced-match@1.0.0", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "balanced-match@1.0.0", | 8 | "_from": "balanced-match@1.0.0", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", | 27 | "_resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", |
28 | "_spec": "1.0.0", | 28 | "_spec": "1.0.0", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "Julian Gruber", | 31 | "name": "Julian Gruber", |
32 | "email": "mail@juliangruber.com", | 32 | "email": "mail@juliangruber.com", | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "basic-auth@2.0.1", | 4 | "basic-auth@2.0.1", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "basic-auth@2.0.1", | 8 | "_from": "basic-auth@2.0.1", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", | 27 | "_resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", |
28 | "_spec": "2.0.1", | 28 | "_spec": "2.0.1", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "bugs": { | 30 | "bugs": { |
31 | "url": "https://github.com/jshttp/basic-auth/issues" | 31 | "url": "https://github.com/jshttp/basic-auth/issues" |
32 | }, | 32 | }, | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "bcrypt-nodejs@0.0.3", | 4 | "bcrypt-nodejs@0.0.3", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "bcrypt-nodejs@0.0.3", | 8 | "_from": "bcrypt-nodejs@0.0.3", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/bcrypt-nodejs/-/bcrypt-nodejs-0.0.3.tgz", | 27 | "_resolved": "https://registry.npmjs.org/bcrypt-nodejs/-/bcrypt-nodejs-0.0.3.tgz", |
28 | "_spec": "0.0.3", | 28 | "_spec": "0.0.3", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "Shane Girish", | 31 | "name": "Shane Girish", |
32 | "email": "shaneGirish@gmail.com" | 32 | "email": "shaneGirish@gmail.com" | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "bcrypt-pbkdf@1.0.2", | 4 | "bcrypt-pbkdf@1.0.2", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "bcrypt-pbkdf@1.0.2", | 8 | "_from": "bcrypt-pbkdf@1.0.2", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", | 27 | "_resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", |
28 | "_spec": "1.0.2", | 28 | "_spec": "1.0.2", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "bugs": { | 30 | "bugs": { |
31 | "url": "https://github.com/joyent/node-bcrypt-pbkdf/issues" | 31 | "url": "https://github.com/joyent/node-bcrypt-pbkdf/issues" |
32 | }, | 32 | }, | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "bignumber.js@4.1.0", | 4 | "bignumber.js@4.1.0", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "bignumber.js@4.1.0", | 8 | "_from": "bignumber.js@4.1.0", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-4.1.0.tgz", | 27 | "_resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-4.1.0.tgz", |
28 | "_spec": "4.1.0", | 28 | "_spec": "4.1.0", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "Michael Mclaughlin", | 31 | "name": "Michael Mclaughlin", |
32 | "email": "M8ch88l@gmail.com" | 32 | "email": "M8ch88l@gmail.com" | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "readable-stream@2.0.6", | 4 | "readable-stream@2.0.6", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "readable-stream@2.0.6", | 8 | "_from": "readable-stream@2.0.6", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", | 27 | "_resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", |
28 | "_spec": "2.0.6", | 28 | "_spec": "2.0.6", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "browser": { | 30 | "browser": { |
31 | "util": false | 31 | "util": false |
32 | }, | 32 | }, | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "string_decoder@0.10.31", | 4 | "string_decoder@0.10.31", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "string_decoder@0.10.31", | 8 | "_from": "string_decoder@0.10.31", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", | 27 | "_resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", |
28 | "_spec": "0.10.31", | 28 | "_spec": "0.10.31", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "bugs": { | 30 | "bugs": { |
31 | "url": "https://github.com/rvagg/string_decoder/issues" | 31 | "url": "https://github.com/rvagg/string_decoder/issues" |
32 | }, | 32 | }, | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "bl@1.0.3", | 4 | "bl@1.0.3", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "bl@1.0.3", | 8 | "_from": "bl@1.0.3", |
... | @@ -32,7 +32,7 @@ | ... | @@ -32,7 +32,7 @@ |
32 | ], | 32 | ], |
33 | "_resolved": "http://registry.npmjs.org/bl/-/bl-1.0.3.tgz", | 33 | "_resolved": "http://registry.npmjs.org/bl/-/bl-1.0.3.tgz", |
34 | "_spec": "1.0.3", | 34 | "_spec": "1.0.3", |
35 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 35 | + "_where": "/Users/star/Desktop/YTMT", |
36 | "authors": [ | 36 | "authors": [ |
37 | "Rod Vagg <rod@vagg.org> (https://github.com/rvagg)", | 37 | "Rod Vagg <rod@vagg.org> (https://github.com/rvagg)", |
38 | "Matteo Collina <matteo.collina@gmail.com> (https://github.com/mcollina)", | 38 | "Matteo Collina <matteo.collina@gmail.com> (https://github.com/mcollina)", | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "bluebird@3.5.1", | 4 | "bluebird@3.5.1", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "bluebird@3.5.1", | 8 | "_from": "bluebird@3.5.1", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", | 27 | "_resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", |
28 | "_spec": "3.5.1", | 28 | "_spec": "3.5.1", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "Petka Antonov", | 31 | "name": "Petka Antonov", |
32 | "email": "petka_antonov@hotmail.com", | 32 | "email": "petka_antonov@hotmail.com", | ... | ... |
1 | +1.19.0 / 2019-04-25 | ||
2 | +=================== | ||
3 | + | ||
4 | + * deps: bytes@3.1.0 | ||
5 | + - Add petabyte (`pb`) support | ||
6 | + * deps: http-errors@1.7.2 | ||
7 | + - Set constructor name when possible | ||
8 | + - deps: setprototypeof@1.1.1 | ||
9 | + - deps: statuses@'>= 1.5.0 < 2' | ||
10 | + * deps: iconv-lite@0.4.24 | ||
11 | + - Added encoding MIK | ||
12 | + * deps: qs@6.7.0 | ||
13 | + - Fix parsing array brackets after index | ||
14 | + * deps: raw-body@2.4.0 | ||
15 | + - deps: bytes@3.1.0 | ||
16 | + - deps: http-errors@1.7.2 | ||
17 | + - deps: iconv-lite@0.4.24 | ||
18 | + * deps: type-is@~1.6.17 | ||
19 | + - deps: mime-types@~2.1.24 | ||
20 | + - perf: prevent internal `throw` on invalid type | ||
21 | + | ||
1 | 1.18.3 / 2018-05-14 | 22 | 1.18.3 / 2018-05-14 |
2 | =================== | 23 | =================== |
3 | 24 | ... | ... |
... | @@ -399,13 +399,11 @@ var urlencodedParser = bodyParser.urlencoded({ extended: false }) | ... | @@ -399,13 +399,11 @@ var urlencodedParser = bodyParser.urlencoded({ extended: false }) |
399 | 399 | ||
400 | // POST /login gets urlencoded bodies | 400 | // POST /login gets urlencoded bodies |
401 | app.post('/login', urlencodedParser, function (req, res) { | 401 | app.post('/login', urlencodedParser, function (req, res) { |
402 | - if (!req.body) return res.sendStatus(400) | ||
403 | res.send('welcome, ' + req.body.username) | 402 | res.send('welcome, ' + req.body.username) |
404 | }) | 403 | }) |
405 | 404 | ||
406 | // POST /api/users gets JSON bodies | 405 | // POST /api/users gets JSON bodies |
407 | app.post('/api/users', jsonParser, function (req, res) { | 406 | app.post('/api/users', jsonParser, function (req, res) { |
408 | - if (!req.body) return res.sendStatus(400) | ||
409 | // create user in req.body | 407 | // create user in req.body |
410 | }) | 408 | }) |
411 | ``` | 409 | ``` | ... | ... |
... | @@ -266,7 +266,7 @@ function simpleparser (options) { | ... | @@ -266,7 +266,7 @@ function simpleparser (options) { |
266 | } | 266 | } |
267 | 267 | ||
268 | debug('parse urlencoding') | 268 | debug('parse urlencoding') |
269 | - return parse(body, undefined, undefined, {maxKeys: parameterLimit}) | 269 | + return parse(body, undefined, undefined, { maxKeys: parameterLimit }) |
270 | } | 270 | } |
271 | } | 271 | } |
272 | 272 | ... | ... |
1 | +2019-02-18 / 1.7.2 | ||
2 | +================== | ||
3 | + | ||
4 | + * deps: setprototypeof@1.1.1 | ||
5 | + | ||
6 | +2018-09-08 / 1.7.1 | ||
7 | +================== | ||
8 | + | ||
9 | + * Fix error creating objects in some environments | ||
10 | + | ||
11 | +2018-07-30 / 1.7.0 | ||
12 | +================== | ||
13 | + | ||
14 | + * Set constructor name when possible | ||
15 | + * Use `toidentifier` module to make class names | ||
16 | + * deps: statuses@'>= 1.5.0 < 2' | ||
17 | + | ||
18 | +2018-03-29 / 1.6.3 | ||
19 | +================== | ||
20 | + | ||
21 | + * deps: depd@~1.1.2 | ||
22 | + - perf: remove argument reassignment | ||
23 | + * deps: setprototypeof@1.1.0 | ||
24 | + * deps: statuses@'>= 1.4.0 < 2' | ||
25 | + | ||
26 | +2017-08-04 / 1.6.2 | ||
27 | +================== | ||
28 | + | ||
29 | + * deps: depd@1.1.1 | ||
30 | + - Remove unnecessary `Buffer` loading | ||
31 | + | ||
32 | +2017-02-20 / 1.6.1 | ||
33 | +================== | ||
34 | + | ||
35 | + * deps: setprototypeof@1.0.3 | ||
36 | + - Fix shim for old browsers | ||
37 | + | ||
38 | +2017-02-14 / 1.6.0 | ||
39 | +================== | ||
40 | + | ||
41 | + * Accept custom 4xx and 5xx status codes in factory | ||
42 | + * Add deprecation message to `"I'mateapot"` export | ||
43 | + * Deprecate passing status code as anything except first argument in factory | ||
44 | + * Deprecate using non-error status codes | ||
45 | + * Make `message` property enumerable for `HttpError`s | ||
46 | + | ||
47 | +2016-11-16 / 1.5.1 | ||
48 | +================== | ||
49 | + | ||
50 | + * deps: inherits@2.0.3 | ||
51 | + - Fix issue loading in browser | ||
52 | + * deps: setprototypeof@1.0.2 | ||
53 | + * deps: statuses@'>= 1.3.1 < 2' | ||
54 | + | ||
55 | +2016-05-18 / 1.5.0 | ||
56 | +================== | ||
57 | + | ||
58 | + * Support new code `421 Misdirected Request` | ||
59 | + * Use `setprototypeof` module to replace `__proto__` setting | ||
60 | + * deps: statuses@'>= 1.3.0 < 2' | ||
61 | + - Add `421 Misdirected Request` | ||
62 | + - perf: enable strict mode | ||
63 | + * perf: enable strict mode | ||
64 | + | ||
65 | +2016-01-28 / 1.4.0 | ||
66 | +================== | ||
67 | + | ||
68 | + * Add `HttpError` export, for `err instanceof createError.HttpError` | ||
69 | + * deps: inherits@2.0.1 | ||
70 | + * deps: statuses@'>= 1.2.1 < 2' | ||
71 | + - Fix message for status 451 | ||
72 | + - Remove incorrect nginx status code | ||
73 | + | ||
74 | +2015-02-02 / 1.3.1 | ||
75 | +================== | ||
76 | + | ||
77 | + * Fix regression where status can be overwritten in `createError` `props` | ||
78 | + | ||
79 | +2015-02-01 / 1.3.0 | ||
80 | +================== | ||
81 | + | ||
82 | + * Construct errors using defined constructors from `createError` | ||
83 | + * Fix error names that are not identifiers | ||
84 | + - `createError["I'mateapot"]` is now `createError.ImATeapot` | ||
85 | + * Set a meaningful `name` property on constructed errors | ||
86 | + | ||
87 | +2014-12-09 / 1.2.8 | ||
88 | +================== | ||
89 | + | ||
90 | + * Fix stack trace from exported function | ||
91 | + * Remove `arguments.callee` usage | ||
92 | + | ||
93 | +2014-10-14 / 1.2.7 | ||
94 | +================== | ||
95 | + | ||
96 | + * Remove duplicate line | ||
97 | + | ||
98 | +2014-10-02 / 1.2.6 | ||
99 | +================== | ||
100 | + | ||
101 | + * Fix `expose` to be `true` for `ClientError` constructor | ||
102 | + | ||
103 | +2014-09-28 / 1.2.5 | ||
104 | +================== | ||
105 | + | ||
106 | + * deps: statuses@1 | ||
107 | + | ||
108 | +2014-09-21 / 1.2.4 | ||
109 | +================== | ||
110 | + | ||
111 | + * Fix dependency version to work with old `npm`s | ||
112 | + | ||
113 | +2014-09-21 / 1.2.3 | ||
114 | +================== | ||
115 | + | ||
116 | + * deps: statuses@~1.1.0 | ||
117 | + | ||
118 | +2014-09-21 / 1.2.2 | ||
119 | +================== | ||
120 | + | ||
121 | + * Fix publish error | ||
122 | + | ||
123 | +2014-09-21 / 1.2.1 | ||
124 | +================== | ||
125 | + | ||
126 | + * Support Node.js 0.6 | ||
127 | + * Use `inherits` instead of `util` | ||
128 | + | ||
129 | +2014-09-09 / 1.2.0 | ||
130 | +================== | ||
131 | + | ||
132 | + * Fix the way inheriting functions | ||
133 | + * Support `expose` being provided in properties argument | ||
134 | + | ||
135 | +2014-09-08 / 1.1.0 | ||
136 | +================== | ||
137 | + | ||
138 | + * Default status to 500 | ||
139 | + * Support provided `error` to extend | ||
140 | + | ||
141 | +2014-09-08 / 1.0.1 | ||
142 | +================== | ||
143 | + | ||
144 | + * Fix accepting string message | ||
145 | + | ||
146 | +2014-09-08 / 1.0.0 | ||
147 | +================== | ||
148 | + | ||
149 | + * Initial release |
1 | + | ||
2 | +The MIT License (MIT) | ||
3 | + | ||
4 | +Copyright (c) 2014 Jonathan Ong me@jongleberry.com | ||
5 | +Copyright (c) 2016 Douglas Christopher Wilson doug@somethingdoug.com | ||
6 | + | ||
7 | +Permission is hereby granted, free of charge, to any person obtaining a copy | ||
8 | +of this software and associated documentation files (the "Software"), to deal | ||
9 | +in the Software without restriction, including without limitation the rights | ||
10 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
11 | +copies of the Software, and to permit persons to whom the Software is | ||
12 | +furnished to do so, subject to the following conditions: | ||
13 | + | ||
14 | +The above copyright notice and this permission notice shall be included in | ||
15 | +all copies or substantial portions of the Software. | ||
16 | + | ||
17 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
18 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
19 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
20 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
21 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
22 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
23 | +THE SOFTWARE. |
1 | +# http-errors | ||
2 | + | ||
3 | +[![NPM Version][npm-version-image]][npm-url] | ||
4 | +[![NPM Downloads][npm-downloads-image]][node-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 | +Create HTTP errors for Express, Koa, Connect, etc. with ease. | ||
10 | + | ||
11 | +## Install | ||
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 | +```bash | ||
18 | +$ npm install http-errors | ||
19 | +``` | ||
20 | + | ||
21 | +## Example | ||
22 | + | ||
23 | +```js | ||
24 | +var createError = require('http-errors') | ||
25 | +var express = require('express') | ||
26 | +var app = express() | ||
27 | + | ||
28 | +app.use(function (req, res, next) { | ||
29 | + if (!req.user) return next(createError(401, 'Please login to view this page.')) | ||
30 | + next() | ||
31 | +}) | ||
32 | +``` | ||
33 | + | ||
34 | +## API | ||
35 | + | ||
36 | +This is the current API, currently extracted from Koa and subject to change. | ||
37 | + | ||
38 | +### Error Properties | ||
39 | + | ||
40 | +- `expose` - can be used to signal if `message` should be sent to the client, | ||
41 | + defaulting to `false` when `status` >= 500 | ||
42 | +- `headers` - can be an object of header names to values to be sent to the | ||
43 | + client, defaulting to `undefined`. When defined, the key names should all | ||
44 | + be lower-cased | ||
45 | +- `message` - the traditional error message, which should be kept short and all | ||
46 | + single line | ||
47 | +- `status` - the status code of the error, mirroring `statusCode` for general | ||
48 | + compatibility | ||
49 | +- `statusCode` - the status code of the error, defaulting to `500` | ||
50 | + | ||
51 | +### createError([status], [message], [properties]) | ||
52 | + | ||
53 | +Create a new error object with the given message `msg`. | ||
54 | +The error object inherits from `createError.HttpError`. | ||
55 | + | ||
56 | +<!-- eslint-disable no-undef, no-unused-vars --> | ||
57 | + | ||
58 | +```js | ||
59 | +var err = createError(404, 'This video does not exist!') | ||
60 | +``` | ||
61 | + | ||
62 | +- `status: 500` - the status code as a number | ||
63 | +- `message` - the message of the error, defaulting to node's text for that status code. | ||
64 | +- `properties` - custom properties to attach to the object | ||
65 | + | ||
66 | +### createError([status], [error], [properties]) | ||
67 | + | ||
68 | +Extend the given `error` object with `createError.HttpError` | ||
69 | +properties. This will not alter the inheritance of the given | ||
70 | +`error` object, and the modified `error` object is the | ||
71 | +return value. | ||
72 | + | ||
73 | +<!-- eslint-disable no-redeclare, no-undef, no-unused-vars --> | ||
74 | + | ||
75 | +```js | ||
76 | +fs.readFile('foo.txt', function (err, buf) { | ||
77 | + if (err) { | ||
78 | + if (err.code === 'ENOENT') { | ||
79 | + var httpError = createError(404, err, { expose: false }) | ||
80 | + } else { | ||
81 | + var httpError = createError(500, err) | ||
82 | + } | ||
83 | + } | ||
84 | +}) | ||
85 | +``` | ||
86 | + | ||
87 | +- `status` - the status code as a number | ||
88 | +- `error` - the error object to extend | ||
89 | +- `properties` - custom properties to attach to the object | ||
90 | + | ||
91 | +### new createError\[code || name\](\[msg]\)) | ||
92 | + | ||
93 | +Create a new error object with the given message `msg`. | ||
94 | +The error object inherits from `createError.HttpError`. | ||
95 | + | ||
96 | +<!-- eslint-disable no-undef, no-unused-vars --> | ||
97 | + | ||
98 | +```js | ||
99 | +var err = new createError.NotFound() | ||
100 | +``` | ||
101 | + | ||
102 | +- `code` - the status code as a number | ||
103 | +- `name` - the name of the error as a "bumpy case", i.e. `NotFound` or `InternalServerError`. | ||
104 | + | ||
105 | +#### List of all constructors | ||
106 | + | ||
107 | +|Status Code|Constructor Name | | ||
108 | +|-----------|-----------------------------| | ||
109 | +|400 |BadRequest | | ||
110 | +|401 |Unauthorized | | ||
111 | +|402 |PaymentRequired | | ||
112 | +|403 |Forbidden | | ||
113 | +|404 |NotFound | | ||
114 | +|405 |MethodNotAllowed | | ||
115 | +|406 |NotAcceptable | | ||
116 | +|407 |ProxyAuthenticationRequired | | ||
117 | +|408 |RequestTimeout | | ||
118 | +|409 |Conflict | | ||
119 | +|410 |Gone | | ||
120 | +|411 |LengthRequired | | ||
121 | +|412 |PreconditionFailed | | ||
122 | +|413 |PayloadTooLarge | | ||
123 | +|414 |URITooLong | | ||
124 | +|415 |UnsupportedMediaType | | ||
125 | +|416 |RangeNotSatisfiable | | ||
126 | +|417 |ExpectationFailed | | ||
127 | +|418 |ImATeapot | | ||
128 | +|421 |MisdirectedRequest | | ||
129 | +|422 |UnprocessableEntity | | ||
130 | +|423 |Locked | | ||
131 | +|424 |FailedDependency | | ||
132 | +|425 |UnorderedCollection | | ||
133 | +|426 |UpgradeRequired | | ||
134 | +|428 |PreconditionRequired | | ||
135 | +|429 |TooManyRequests | | ||
136 | +|431 |RequestHeaderFieldsTooLarge | | ||
137 | +|451 |UnavailableForLegalReasons | | ||
138 | +|500 |InternalServerError | | ||
139 | +|501 |NotImplemented | | ||
140 | +|502 |BadGateway | | ||
141 | +|503 |ServiceUnavailable | | ||
142 | +|504 |GatewayTimeout | | ||
143 | +|505 |HTTPVersionNotSupported | | ||
144 | +|506 |VariantAlsoNegotiates | | ||
145 | +|507 |InsufficientStorage | | ||
146 | +|508 |LoopDetected | | ||
147 | +|509 |BandwidthLimitExceeded | | ||
148 | +|510 |NotExtended | | ||
149 | +|511 |NetworkAuthenticationRequired| | ||
150 | + | ||
151 | +## License | ||
152 | + | ||
153 | +[MIT](LICENSE) | ||
154 | + | ||
155 | +[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/http-errors/master | ||
156 | +[coveralls-url]: https://coveralls.io/r/jshttp/http-errors?branch=master | ||
157 | +[node-image]: https://badgen.net/npm/node/http-errors | ||
158 | +[node-url]: https://nodejs.org/en/download | ||
159 | +[npm-downloads-image]: https://badgen.net/npm/dm/http-errors | ||
160 | +[npm-url]: https://npmjs.org/package/http-errors | ||
161 | +[npm-version-image]: https://badgen.net/npm/v/http-errors | ||
162 | +[travis-image]: https://badgen.net/travis/jshttp/http-errors/master | ||
163 | +[travis-url]: https://travis-ci.org/jshttp/http-errors |
1 | +/*! | ||
2 | + * http-errors | ||
3 | + * Copyright(c) 2014 Jonathan Ong | ||
4 | + * Copyright(c) 2016 Douglas Christopher Wilson | ||
5 | + * MIT Licensed | ||
6 | + */ | ||
7 | + | ||
8 | +'use strict' | ||
9 | + | ||
10 | +/** | ||
11 | + * Module dependencies. | ||
12 | + * @private | ||
13 | + */ | ||
14 | + | ||
15 | +var deprecate = require('depd')('http-errors') | ||
16 | +var setPrototypeOf = require('setprototypeof') | ||
17 | +var statuses = require('statuses') | ||
18 | +var inherits = require('inherits') | ||
19 | +var toIdentifier = require('toidentifier') | ||
20 | + | ||
21 | +/** | ||
22 | + * Module exports. | ||
23 | + * @public | ||
24 | + */ | ||
25 | + | ||
26 | +module.exports = createError | ||
27 | +module.exports.HttpError = createHttpErrorConstructor() | ||
28 | + | ||
29 | +// Populate exports for all constructors | ||
30 | +populateConstructorExports(module.exports, statuses.codes, module.exports.HttpError) | ||
31 | + | ||
32 | +/** | ||
33 | + * Get the code class of a status code. | ||
34 | + * @private | ||
35 | + */ | ||
36 | + | ||
37 | +function codeClass (status) { | ||
38 | + return Number(String(status).charAt(0) + '00') | ||
39 | +} | ||
40 | + | ||
41 | +/** | ||
42 | + * Create a new HTTP Error. | ||
43 | + * | ||
44 | + * @returns {Error} | ||
45 | + * @public | ||
46 | + */ | ||
47 | + | ||
48 | +function createError () { | ||
49 | + // so much arity going on ~_~ | ||
50 | + var err | ||
51 | + var msg | ||
52 | + var status = 500 | ||
53 | + var props = {} | ||
54 | + for (var i = 0; i < arguments.length; i++) { | ||
55 | + var arg = arguments[i] | ||
56 | + if (arg instanceof Error) { | ||
57 | + err = arg | ||
58 | + status = err.status || err.statusCode || status | ||
59 | + continue | ||
60 | + } | ||
61 | + switch (typeof arg) { | ||
62 | + case 'string': | ||
63 | + msg = arg | ||
64 | + break | ||
65 | + case 'number': | ||
66 | + status = arg | ||
67 | + if (i !== 0) { | ||
68 | + deprecate('non-first-argument status code; replace with createError(' + arg + ', ...)') | ||
69 | + } | ||
70 | + break | ||
71 | + case 'object': | ||
72 | + props = arg | ||
73 | + break | ||
74 | + } | ||
75 | + } | ||
76 | + | ||
77 | + if (typeof status === 'number' && (status < 400 || status >= 600)) { | ||
78 | + deprecate('non-error status code; use only 4xx or 5xx status codes') | ||
79 | + } | ||
80 | + | ||
81 | + if (typeof status !== 'number' || | ||
82 | + (!statuses[status] && (status < 400 || status >= 600))) { | ||
83 | + status = 500 | ||
84 | + } | ||
85 | + | ||
86 | + // constructor | ||
87 | + var HttpError = createError[status] || createError[codeClass(status)] | ||
88 | + | ||
89 | + if (!err) { | ||
90 | + // create error | ||
91 | + err = HttpError | ||
92 | + ? new HttpError(msg) | ||
93 | + : new Error(msg || statuses[status]) | ||
94 | + Error.captureStackTrace(err, createError) | ||
95 | + } | ||
96 | + | ||
97 | + if (!HttpError || !(err instanceof HttpError) || err.status !== status) { | ||
98 | + // add properties to generic error | ||
99 | + err.expose = status < 500 | ||
100 | + err.status = err.statusCode = status | ||
101 | + } | ||
102 | + | ||
103 | + for (var key in props) { | ||
104 | + if (key !== 'status' && key !== 'statusCode') { | ||
105 | + err[key] = props[key] | ||
106 | + } | ||
107 | + } | ||
108 | + | ||
109 | + return err | ||
110 | +} | ||
111 | + | ||
112 | +/** | ||
113 | + * Create HTTP error abstract base class. | ||
114 | + * @private | ||
115 | + */ | ||
116 | + | ||
117 | +function createHttpErrorConstructor () { | ||
118 | + function HttpError () { | ||
119 | + throw new TypeError('cannot construct abstract class') | ||
120 | + } | ||
121 | + | ||
122 | + inherits(HttpError, Error) | ||
123 | + | ||
124 | + return HttpError | ||
125 | +} | ||
126 | + | ||
127 | +/** | ||
128 | + * Create a constructor for a client error. | ||
129 | + * @private | ||
130 | + */ | ||
131 | + | ||
132 | +function createClientErrorConstructor (HttpError, name, code) { | ||
133 | + var className = name.match(/Error$/) ? name : name + 'Error' | ||
134 | + | ||
135 | + function ClientError (message) { | ||
136 | + // create the error object | ||
137 | + var msg = message != null ? message : statuses[code] | ||
138 | + var err = new Error(msg) | ||
139 | + | ||
140 | + // capture a stack trace to the construction point | ||
141 | + Error.captureStackTrace(err, ClientError) | ||
142 | + | ||
143 | + // adjust the [[Prototype]] | ||
144 | + setPrototypeOf(err, ClientError.prototype) | ||
145 | + | ||
146 | + // redefine the error message | ||
147 | + Object.defineProperty(err, 'message', { | ||
148 | + enumerable: true, | ||
149 | + configurable: true, | ||
150 | + value: msg, | ||
151 | + writable: true | ||
152 | + }) | ||
153 | + | ||
154 | + // redefine the error name | ||
155 | + Object.defineProperty(err, 'name', { | ||
156 | + enumerable: false, | ||
157 | + configurable: true, | ||
158 | + value: className, | ||
159 | + writable: true | ||
160 | + }) | ||
161 | + | ||
162 | + return err | ||
163 | + } | ||
164 | + | ||
165 | + inherits(ClientError, HttpError) | ||
166 | + nameFunc(ClientError, className) | ||
167 | + | ||
168 | + ClientError.prototype.status = code | ||
169 | + ClientError.prototype.statusCode = code | ||
170 | + ClientError.prototype.expose = true | ||
171 | + | ||
172 | + return ClientError | ||
173 | +} | ||
174 | + | ||
175 | +/** | ||
176 | + * Create a constructor for a server error. | ||
177 | + * @private | ||
178 | + */ | ||
179 | + | ||
180 | +function createServerErrorConstructor (HttpError, name, code) { | ||
181 | + var className = name.match(/Error$/) ? name : name + 'Error' | ||
182 | + | ||
183 | + function ServerError (message) { | ||
184 | + // create the error object | ||
185 | + var msg = message != null ? message : statuses[code] | ||
186 | + var err = new Error(msg) | ||
187 | + | ||
188 | + // capture a stack trace to the construction point | ||
189 | + Error.captureStackTrace(err, ServerError) | ||
190 | + | ||
191 | + // adjust the [[Prototype]] | ||
192 | + setPrototypeOf(err, ServerError.prototype) | ||
193 | + | ||
194 | + // redefine the error message | ||
195 | + Object.defineProperty(err, 'message', { | ||
196 | + enumerable: true, | ||
197 | + configurable: true, | ||
198 | + value: msg, | ||
199 | + writable: true | ||
200 | + }) | ||
201 | + | ||
202 | + // redefine the error name | ||
203 | + Object.defineProperty(err, 'name', { | ||
204 | + enumerable: false, | ||
205 | + configurable: true, | ||
206 | + value: className, | ||
207 | + writable: true | ||
208 | + }) | ||
209 | + | ||
210 | + return err | ||
211 | + } | ||
212 | + | ||
213 | + inherits(ServerError, HttpError) | ||
214 | + nameFunc(ServerError, className) | ||
215 | + | ||
216 | + ServerError.prototype.status = code | ||
217 | + ServerError.prototype.statusCode = code | ||
218 | + ServerError.prototype.expose = false | ||
219 | + | ||
220 | + return ServerError | ||
221 | +} | ||
222 | + | ||
223 | +/** | ||
224 | + * Set the name of a function, if possible. | ||
225 | + * @private | ||
226 | + */ | ||
227 | + | ||
228 | +function nameFunc (func, name) { | ||
229 | + var desc = Object.getOwnPropertyDescriptor(func, 'name') | ||
230 | + | ||
231 | + if (desc && desc.configurable) { | ||
232 | + desc.value = name | ||
233 | + Object.defineProperty(func, 'name', desc) | ||
234 | + } | ||
235 | +} | ||
236 | + | ||
237 | +/** | ||
238 | + * Populate the exports object with constructors for every error class. | ||
239 | + * @private | ||
240 | + */ | ||
241 | + | ||
242 | +function populateConstructorExports (exports, codes, HttpError) { | ||
243 | + codes.forEach(function forEachCode (code) { | ||
244 | + var CodeError | ||
245 | + var name = toIdentifier(statuses[code]) | ||
246 | + | ||
247 | + switch (codeClass(code)) { | ||
248 | + case 400: | ||
249 | + CodeError = createClientErrorConstructor(HttpError, name, code) | ||
250 | + break | ||
251 | + case 500: | ||
252 | + CodeError = createServerErrorConstructor(HttpError, name, code) | ||
253 | + break | ||
254 | + } | ||
255 | + | ||
256 | + if (CodeError) { | ||
257 | + // export the constructor | ||
258 | + exports[code] = CodeError | ||
259 | + exports[name] = CodeError | ||
260 | + } | ||
261 | + }) | ||
262 | + | ||
263 | + // backwards-compatibility | ||
264 | + exports["I'mateapot"] = deprecate.function(exports.ImATeapot, | ||
265 | + '"I\'mateapot"; use "ImATeapot" instead') | ||
266 | +} |
1 | +{ | ||
2 | + "_args": [ | ||
3 | + [ | ||
4 | + "http-errors@1.7.2", | ||
5 | + "/Users/star/Desktop/YTMT" | ||
6 | + ] | ||
7 | + ], | ||
8 | + "_from": "http-errors@1.7.2", | ||
9 | + "_id": "http-errors@1.7.2", | ||
10 | + "_inBundle": false, | ||
11 | + "_integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", | ||
12 | + "_location": "/body-parser/http-errors", | ||
13 | + "_phantomChildren": {}, | ||
14 | + "_requested": { | ||
15 | + "type": "version", | ||
16 | + "registry": true, | ||
17 | + "raw": "http-errors@1.7.2", | ||
18 | + "name": "http-errors", | ||
19 | + "escapedName": "http-errors", | ||
20 | + "rawSpec": "1.7.2", | ||
21 | + "saveSpec": null, | ||
22 | + "fetchSpec": "1.7.2" | ||
23 | + }, | ||
24 | + "_requiredBy": [ | ||
25 | + "/body-parser" | ||
26 | + ], | ||
27 | + "_resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", | ||
28 | + "_spec": "1.7.2", | ||
29 | + "_where": "/Users/star/Desktop/YTMT", | ||
30 | + "author": { | ||
31 | + "name": "Jonathan Ong", | ||
32 | + "email": "me@jongleberry.com", | ||
33 | + "url": "http://jongleberry.com" | ||
34 | + }, | ||
35 | + "bugs": { | ||
36 | + "url": "https://github.com/jshttp/http-errors/issues" | ||
37 | + }, | ||
38 | + "contributors": [ | ||
39 | + { | ||
40 | + "name": "Alan Plum", | ||
41 | + "email": "me@pluma.io" | ||
42 | + }, | ||
43 | + { | ||
44 | + "name": "Douglas Christopher Wilson", | ||
45 | + "email": "doug@somethingdoug.com" | ||
46 | + } | ||
47 | + ], | ||
48 | + "dependencies": { | ||
49 | + "depd": "~1.1.2", | ||
50 | + "inherits": "2.0.3", | ||
51 | + "setprototypeof": "1.1.1", | ||
52 | + "statuses": ">= 1.5.0 < 2", | ||
53 | + "toidentifier": "1.0.0" | ||
54 | + }, | ||
55 | + "description": "Create HTTP error objects", | ||
56 | + "devDependencies": { | ||
57 | + "eslint": "5.13.0", | ||
58 | + "eslint-config-standard": "12.0.0", | ||
59 | + "eslint-plugin-import": "2.16.0", | ||
60 | + "eslint-plugin-markdown": "1.0.0", | ||
61 | + "eslint-plugin-node": "7.0.1", | ||
62 | + "eslint-plugin-promise": "4.0.1", | ||
63 | + "eslint-plugin-standard": "4.0.0", | ||
64 | + "istanbul": "0.4.5", | ||
65 | + "mocha": "5.2.0" | ||
66 | + }, | ||
67 | + "engines": { | ||
68 | + "node": ">= 0.6" | ||
69 | + }, | ||
70 | + "files": [ | ||
71 | + "index.js", | ||
72 | + "HISTORY.md", | ||
73 | + "LICENSE", | ||
74 | + "README.md" | ||
75 | + ], | ||
76 | + "homepage": "https://github.com/jshttp/http-errors#readme", | ||
77 | + "keywords": [ | ||
78 | + "http", | ||
79 | + "error" | ||
80 | + ], | ||
81 | + "license": "MIT", | ||
82 | + "name": "http-errors", | ||
83 | + "repository": { | ||
84 | + "type": "git", | ||
85 | + "url": "git+https://github.com/jshttp/http-errors.git" | ||
86 | + }, | ||
87 | + "scripts": { | ||
88 | + "lint": "eslint --plugin markdown --ext js,md . && node ./scripts/lint-readme-list.js", | ||
89 | + "test": "mocha --reporter spec --bail", | ||
90 | + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot", | ||
91 | + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot" | ||
92 | + }, | ||
93 | + "version": "1.7.2" | ||
94 | +} |
This diff is collapsed. Click to expand it.
1 | + | ||
2 | +The MIT License (MIT) | ||
3 | + | ||
4 | +Copyright (c) 2014 Jonathan Ong me@jongleberry.com | ||
5 | + | ||
6 | +Permission is hereby granted, free of charge, to any person obtaining a copy | ||
7 | +of this software and associated documentation files (the "Software"), to deal | ||
8 | +in the Software without restriction, including without limitation the rights | ||
9 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
10 | +copies of the Software, and to permit persons to whom the Software is | ||
11 | +furnished to do so, subject to the following conditions: | ||
12 | + | ||
13 | +The above copyright notice and this permission notice shall be included in | ||
14 | +all copies or substantial portions of the Software. | ||
15 | + | ||
16 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
17 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
18 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
19 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
20 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
21 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
22 | +THE SOFTWARE. |
1 | +# mime-db | ||
2 | + | ||
3 | +[![NPM Version][npm-version-image]][npm-url] | ||
4 | +[![NPM Downloads][npm-downloads-image]][npm-url] | ||
5 | +[![Node.js Version][node-image]][node-url] | ||
6 | +[![Build Status][travis-image]][travis-url] | ||
7 | +[![Coverage Status][coveralls-image]][coveralls-url] | ||
8 | + | ||
9 | +This is a database of all mime types. | ||
10 | +It consists of a single, public JSON file and does not include any logic, | ||
11 | +allowing it to remain as un-opinionated as possible with an API. | ||
12 | +It aggregates data from the following sources: | ||
13 | + | ||
14 | +- http://www.iana.org/assignments/media-types/media-types.xhtml | ||
15 | +- http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types | ||
16 | +- http://hg.nginx.org/nginx/raw-file/default/conf/mime.types | ||
17 | + | ||
18 | +## Installation | ||
19 | + | ||
20 | +```bash | ||
21 | +npm install mime-db | ||
22 | +``` | ||
23 | + | ||
24 | +### Database Download | ||
25 | + | ||
26 | +If you're crazy enough to use this in the browser, you can just grab the | ||
27 | +JSON file using [jsDelivr](https://www.jsdelivr.com/). It is recommended to | ||
28 | +replace `master` with [a release tag](https://github.com/jshttp/mime-db/tags) | ||
29 | +as the JSON format may change in the future. | ||
30 | + | ||
31 | +``` | ||
32 | +https://cdn.jsdelivr.net/gh/jshttp/mime-db@master/db.json | ||
33 | +``` | ||
34 | + | ||
35 | +## Usage | ||
36 | + | ||
37 | +```js | ||
38 | +var db = require('mime-db'); | ||
39 | + | ||
40 | +// grab data on .js files | ||
41 | +var data = db['application/javascript']; | ||
42 | +``` | ||
43 | + | ||
44 | +## Data Structure | ||
45 | + | ||
46 | +The JSON file is a map lookup for lowercased mime types. | ||
47 | +Each mime type has the following properties: | ||
48 | + | ||
49 | +- `.source` - where the mime type is defined. | ||
50 | + If not set, it's probably a custom media type. | ||
51 | + - `apache` - [Apache common media types](http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types) | ||
52 | + - `iana` - [IANA-defined media types](http://www.iana.org/assignments/media-types/media-types.xhtml) | ||
53 | + - `nginx` - [nginx media types](http://hg.nginx.org/nginx/raw-file/default/conf/mime.types) | ||
54 | +- `.extensions[]` - known extensions associated with this mime type. | ||
55 | +- `.compressible` - whether a file of this type can be gzipped. | ||
56 | +- `.charset` - the default charset associated with this type, if any. | ||
57 | + | ||
58 | +If unknown, every property could be `undefined`. | ||
59 | + | ||
60 | +## Contributing | ||
61 | + | ||
62 | +To edit the database, only make PRs against `src/custom.json` or | ||
63 | +`src/custom-suffix.json`. | ||
64 | + | ||
65 | +The `src/custom.json` file is a JSON object with the MIME type as the keys | ||
66 | +and the values being an object with the following keys: | ||
67 | + | ||
68 | +- `compressible` - leave out if you don't know, otherwise `true`/`false` to | ||
69 | + indicate whether the data represented by the type is typically compressible. | ||
70 | +- `extensions` - include an array of file extensions that are associated with | ||
71 | + the type. | ||
72 | +- `notes` - human-readable notes about the type, typically what the type is. | ||
73 | +- `sources` - include an array of URLs of where the MIME type and the associated | ||
74 | + extensions are sourced from. This needs to be a [primary source](https://en.wikipedia.org/wiki/Primary_source); | ||
75 | + links to type aggregating sites and Wikipedia are _not acceptable_. | ||
76 | + | ||
77 | +To update the build, run `npm run build`. | ||
78 | + | ||
79 | +### Adding Custom Media Types | ||
80 | + | ||
81 | +The best way to get new media types included in this library is to register | ||
82 | +them with the IANA. The community registration procedure is outlined in | ||
83 | +[RFC 6838 section 5](http://tools.ietf.org/html/rfc6838#section-5). Types | ||
84 | +registered with the IANA are automatically pulled into this library. | ||
85 | + | ||
86 | +If that is not possible / feasible, they can be added directly here as a | ||
87 | +"custom" type. To do this, it is required to have a primary source that | ||
88 | +definitively lists the media type. If an extension is going to be listed as | ||
89 | +associateed with this media type, the source must definitively link the | ||
90 | +media type and extension as well. | ||
91 | + | ||
92 | +[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/mime-db/master | ||
93 | +[coveralls-url]: https://coveralls.io/r/jshttp/mime-db?branch=master | ||
94 | +[node-image]: https://badgen.net/npm/node/mime-db | ||
95 | +[node-url]: https://nodejs.org/en/download | ||
96 | +[npm-downloads-image]: https://badgen.net/npm/dm/mime-db | ||
97 | +[npm-url]: https://npmjs.org/package/mime-db | ||
98 | +[npm-version-image]: https://badgen.net/npm/v/mime-db | ||
99 | +[travis-image]: https://badgen.net/travis/jshttp/mime-db/master | ||
100 | +[travis-url]: https://travis-ci.org/jshttp/mime-db |
This diff could not be displayed because it is too large.
1 | +{ | ||
2 | + "_args": [ | ||
3 | + [ | ||
4 | + "mime-db@1.42.0", | ||
5 | + "/Users/star/Desktop/YTMT" | ||
6 | + ] | ||
7 | + ], | ||
8 | + "_from": "mime-db@1.42.0", | ||
9 | + "_id": "mime-db@1.42.0", | ||
10 | + "_inBundle": false, | ||
11 | + "_integrity": "sha512-UbfJCR4UAVRNgMpfImz05smAXK7+c+ZntjaA26ANtkXLlOe947Aag5zdIcKQULAiF9Cq4WxBi9jUs5zkA84bYQ==", | ||
12 | + "_location": "/body-parser/mime-db", | ||
13 | + "_phantomChildren": {}, | ||
14 | + "_requested": { | ||
15 | + "type": "version", | ||
16 | + "registry": true, | ||
17 | + "raw": "mime-db@1.42.0", | ||
18 | + "name": "mime-db", | ||
19 | + "escapedName": "mime-db", | ||
20 | + "rawSpec": "1.42.0", | ||
21 | + "saveSpec": null, | ||
22 | + "fetchSpec": "1.42.0" | ||
23 | + }, | ||
24 | + "_requiredBy": [ | ||
25 | + "/body-parser/mime-types" | ||
26 | + ], | ||
27 | + "_resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.42.0.tgz", | ||
28 | + "_spec": "1.42.0", | ||
29 | + "_where": "/Users/star/Desktop/YTMT", | ||
30 | + "bugs": { | ||
31 | + "url": "https://github.com/jshttp/mime-db/issues" | ||
32 | + }, | ||
33 | + "contributors": [ | ||
34 | + { | ||
35 | + "name": "Douglas Christopher Wilson", | ||
36 | + "email": "doug@somethingdoug.com" | ||
37 | + }, | ||
38 | + { | ||
39 | + "name": "Jonathan Ong", | ||
40 | + "email": "me@jongleberry.com", | ||
41 | + "url": "http://jongleberry.com" | ||
42 | + }, | ||
43 | + { | ||
44 | + "name": "Robert Kieffer", | ||
45 | + "email": "robert@broofa.com", | ||
46 | + "url": "http://github.com/broofa" | ||
47 | + } | ||
48 | + ], | ||
49 | + "description": "Media Type Database", | ||
50 | + "devDependencies": { | ||
51 | + "bluebird": "3.5.5", | ||
52 | + "co": "4.6.0", | ||
53 | + "cogent": "1.0.1", | ||
54 | + "csv-parse": "4.4.6", | ||
55 | + "eslint": "6.4.0", | ||
56 | + "eslint-config-standard": "14.1.0", | ||
57 | + "eslint-plugin-import": "2.18.2", | ||
58 | + "eslint-plugin-node": "10.0.0", | ||
59 | + "eslint-plugin-promise": "4.2.1", | ||
60 | + "eslint-plugin-standard": "4.0.1", | ||
61 | + "gnode": "0.1.2", | ||
62 | + "mocha": "6.2.0", | ||
63 | + "nyc": "14.1.1", | ||
64 | + "raw-body": "2.4.1", | ||
65 | + "stream-to-array": "2.3.0" | ||
66 | + }, | ||
67 | + "engines": { | ||
68 | + "node": ">= 0.6" | ||
69 | + }, | ||
70 | + "files": [ | ||
71 | + "HISTORY.md", | ||
72 | + "LICENSE", | ||
73 | + "README.md", | ||
74 | + "db.json", | ||
75 | + "index.js" | ||
76 | + ], | ||
77 | + "homepage": "https://github.com/jshttp/mime-db#readme", | ||
78 | + "keywords": [ | ||
79 | + "mime", | ||
80 | + "db", | ||
81 | + "type", | ||
82 | + "types", | ||
83 | + "database", | ||
84 | + "charset", | ||
85 | + "charsets" | ||
86 | + ], | ||
87 | + "license": "MIT", | ||
88 | + "name": "mime-db", | ||
89 | + "repository": { | ||
90 | + "type": "git", | ||
91 | + "url": "git+https://github.com/jshttp/mime-db.git" | ||
92 | + }, | ||
93 | + "scripts": { | ||
94 | + "build": "node scripts/build", | ||
95 | + "fetch": "node scripts/fetch-apache && gnode scripts/fetch-iana && node scripts/fetch-nginx", | ||
96 | + "lint": "eslint .", | ||
97 | + "test": "mocha --reporter spec --bail --check-leaks test/", | ||
98 | + "test-cov": "nyc --reporter=html --reporter=text npm test", | ||
99 | + "test-travis": "nyc --reporter=text npm test", | ||
100 | + "update": "npm run fetch && npm run build", | ||
101 | + "version": "node scripts/version-history.js && git add HISTORY.md" | ||
102 | + }, | ||
103 | + "version": "1.42.0" | ||
104 | +} |
1 | +2.1.25 / 2019-11-12 | ||
2 | +=================== | ||
3 | + | ||
4 | + * deps: mime-db@1.42.0 | ||
5 | + - Add new upstream MIME types | ||
6 | + - Add `application/toml` with extension `.toml` | ||
7 | + - Add `image/vnd.ms-dds` with extension `.dds` | ||
8 | + | ||
9 | +2.1.24 / 2019-04-20 | ||
10 | +=================== | ||
11 | + | ||
12 | + * deps: mime-db@1.40.0 | ||
13 | + - Add extensions from IANA for `model/*` types | ||
14 | + - Add `text/mdx` with extension `.mdx` | ||
15 | + | ||
16 | +2.1.23 / 2019-04-17 | ||
17 | +=================== | ||
18 | + | ||
19 | + * deps: mime-db@~1.39.0 | ||
20 | + - Add extensions `.siv` and `.sieve` to `application/sieve` | ||
21 | + - Add new upstream MIME types | ||
22 | + | ||
23 | +2.1.22 / 2019-02-14 | ||
24 | +=================== | ||
25 | + | ||
26 | + * deps: mime-db@~1.38.0 | ||
27 | + - Add extension `.nq` to `application/n-quads` | ||
28 | + - Add extension `.nt` to `application/n-triples` | ||
29 | + - Add new upstream MIME types | ||
30 | + - Mark `text/less` as compressible | ||
31 | + | ||
32 | +2.1.21 / 2018-10-19 | ||
33 | +=================== | ||
34 | + | ||
35 | + * deps: mime-db@~1.37.0 | ||
36 | + - Add extensions to HEIC image types | ||
37 | + - Add new upstream MIME types | ||
38 | + | ||
39 | +2.1.20 / 2018-08-26 | ||
40 | +=================== | ||
41 | + | ||
42 | + * deps: mime-db@~1.36.0 | ||
43 | + - Add Apple file extensions from IANA | ||
44 | + - Add extensions from IANA for `image/*` types | ||
45 | + - Add new upstream MIME types | ||
46 | + | ||
47 | +2.1.19 / 2018-07-17 | ||
48 | +=================== | ||
49 | + | ||
50 | + * deps: mime-db@~1.35.0 | ||
51 | + - Add extension `.csl` to `application/vnd.citationstyles.style+xml` | ||
52 | + - Add extension `.es` to `application/ecmascript` | ||
53 | + - Add extension `.owl` to `application/rdf+xml` | ||
54 | + - Add new upstream MIME types | ||
55 | + - Add UTF-8 as default charset for `text/turtle` | ||
56 | + | ||
57 | +2.1.18 / 2018-02-16 | ||
58 | +=================== | ||
59 | + | ||
60 | + * deps: mime-db@~1.33.0 | ||
61 | + - Add `application/raml+yaml` with extension `.raml` | ||
62 | + - Add `application/wasm` with extension `.wasm` | ||
63 | + - Add `text/shex` with extension `.shex` | ||
64 | + - Add extensions for JPEG-2000 images | ||
65 | + - Add extensions from IANA for `message/*` types | ||
66 | + - Add new upstream MIME types | ||
67 | + - Update font MIME types | ||
68 | + - Update `text/hjson` to registered `application/hjson` | ||
69 | + | ||
70 | +2.1.17 / 2017-09-01 | ||
71 | +=================== | ||
72 | + | ||
73 | + * deps: mime-db@~1.30.0 | ||
74 | + - Add `application/vnd.ms-outlook` | ||
75 | + - Add `application/x-arj` | ||
76 | + - Add extension `.mjs` to `application/javascript` | ||
77 | + - Add glTF types and extensions | ||
78 | + - Add new upstream MIME types | ||
79 | + - Add `text/x-org` | ||
80 | + - Add VirtualBox MIME types | ||
81 | + - Fix `source` records for `video/*` types that are IANA | ||
82 | + - Update `font/opentype` to registered `font/otf` | ||
83 | + | ||
84 | +2.1.16 / 2017-07-24 | ||
85 | +=================== | ||
86 | + | ||
87 | + * deps: mime-db@~1.29.0 | ||
88 | + - Add `application/fido.trusted-apps+json` | ||
89 | + - Add extension `.wadl` to `application/vnd.sun.wadl+xml` | ||
90 | + - Add extension `.gz` to `application/gzip` | ||
91 | + - Add new upstream MIME types | ||
92 | + - Update extensions `.md` and `.markdown` to be `text/markdown` | ||
93 | + | ||
94 | +2.1.15 / 2017-03-23 | ||
95 | +=================== | ||
96 | + | ||
97 | + * deps: mime-db@~1.27.0 | ||
98 | + - Add new mime types | ||
99 | + - Add `image/apng` | ||
100 | + | ||
101 | +2.1.14 / 2017-01-14 | ||
102 | +=================== | ||
103 | + | ||
104 | + * deps: mime-db@~1.26.0 | ||
105 | + - Add new mime types | ||
106 | + | ||
107 | +2.1.13 / 2016-11-18 | ||
108 | +=================== | ||
109 | + | ||
110 | + * deps: mime-db@~1.25.0 | ||
111 | + - Add new mime types | ||
112 | + | ||
113 | +2.1.12 / 2016-09-18 | ||
114 | +=================== | ||
115 | + | ||
116 | + * deps: mime-db@~1.24.0 | ||
117 | + - Add new mime types | ||
118 | + - Add `audio/mp3` | ||
119 | + | ||
120 | +2.1.11 / 2016-05-01 | ||
121 | +=================== | ||
122 | + | ||
123 | + * deps: mime-db@~1.23.0 | ||
124 | + - Add new mime types | ||
125 | + | ||
126 | +2.1.10 / 2016-02-15 | ||
127 | +=================== | ||
128 | + | ||
129 | + * deps: mime-db@~1.22.0 | ||
130 | + - Add new mime types | ||
131 | + - Fix extension of `application/dash+xml` | ||
132 | + - Update primary extension for `audio/mp4` | ||
133 | + | ||
134 | +2.1.9 / 2016-01-06 | ||
135 | +================== | ||
136 | + | ||
137 | + * deps: mime-db@~1.21.0 | ||
138 | + - Add new mime types | ||
139 | + | ||
140 | +2.1.8 / 2015-11-30 | ||
141 | +================== | ||
142 | + | ||
143 | + * deps: mime-db@~1.20.0 | ||
144 | + - Add new mime types | ||
145 | + | ||
146 | +2.1.7 / 2015-09-20 | ||
147 | +================== | ||
148 | + | ||
149 | + * deps: mime-db@~1.19.0 | ||
150 | + - Add new mime types | ||
151 | + | ||
152 | +2.1.6 / 2015-09-03 | ||
153 | +================== | ||
154 | + | ||
155 | + * deps: mime-db@~1.18.0 | ||
156 | + - Add new mime types | ||
157 | + | ||
158 | +2.1.5 / 2015-08-20 | ||
159 | +================== | ||
160 | + | ||
161 | + * deps: mime-db@~1.17.0 | ||
162 | + - Add new mime types | ||
163 | + | ||
164 | +2.1.4 / 2015-07-30 | ||
165 | +================== | ||
166 | + | ||
167 | + * deps: mime-db@~1.16.0 | ||
168 | + - Add new mime types | ||
169 | + | ||
170 | +2.1.3 / 2015-07-13 | ||
171 | +================== | ||
172 | + | ||
173 | + * deps: mime-db@~1.15.0 | ||
174 | + - Add new mime types | ||
175 | + | ||
176 | +2.1.2 / 2015-06-25 | ||
177 | +================== | ||
178 | + | ||
179 | + * deps: mime-db@~1.14.0 | ||
180 | + - Add new mime types | ||
181 | + | ||
182 | +2.1.1 / 2015-06-08 | ||
183 | +================== | ||
184 | + | ||
185 | + * perf: fix deopt during mapping | ||
186 | + | ||
187 | +2.1.0 / 2015-06-07 | ||
188 | +================== | ||
189 | + | ||
190 | + * Fix incorrectly treating extension-less file name as extension | ||
191 | + - i.e. `'path/to/json'` will no longer return `application/json` | ||
192 | + * Fix `.charset(type)` to accept parameters | ||
193 | + * Fix `.charset(type)` to match case-insensitive | ||
194 | + * Improve generation of extension to MIME mapping | ||
195 | + * Refactor internals for readability and no argument reassignment | ||
196 | + * Prefer `application/*` MIME types from the same source | ||
197 | + * Prefer any type over `application/octet-stream` | ||
198 | + * deps: mime-db@~1.13.0 | ||
199 | + - Add nginx as a source | ||
200 | + - Add new mime types | ||
201 | + | ||
202 | +2.0.14 / 2015-06-06 | ||
203 | +=================== | ||
204 | + | ||
205 | + * deps: mime-db@~1.12.0 | ||
206 | + - Add new mime types | ||
207 | + | ||
208 | +2.0.13 / 2015-05-31 | ||
209 | +=================== | ||
210 | + | ||
211 | + * deps: mime-db@~1.11.0 | ||
212 | + - Add new mime types | ||
213 | + | ||
214 | +2.0.12 / 2015-05-19 | ||
215 | +=================== | ||
216 | + | ||
217 | + * deps: mime-db@~1.10.0 | ||
218 | + - Add new mime types | ||
219 | + | ||
220 | +2.0.11 / 2015-05-05 | ||
221 | +=================== | ||
222 | + | ||
223 | + * deps: mime-db@~1.9.1 | ||
224 | + - Add new mime types | ||
225 | + | ||
226 | +2.0.10 / 2015-03-13 | ||
227 | +=================== | ||
228 | + | ||
229 | + * deps: mime-db@~1.8.0 | ||
230 | + - Add new mime types | ||
231 | + | ||
232 | +2.0.9 / 2015-02-09 | ||
233 | +================== | ||
234 | + | ||
235 | + * deps: mime-db@~1.7.0 | ||
236 | + - Add new mime types | ||
237 | + - Community extensions ownership transferred from `node-mime` | ||
238 | + | ||
239 | +2.0.8 / 2015-01-29 | ||
240 | +================== | ||
241 | + | ||
242 | + * deps: mime-db@~1.6.0 | ||
243 | + - Add new mime types | ||
244 | + | ||
245 | +2.0.7 / 2014-12-30 | ||
246 | +================== | ||
247 | + | ||
248 | + * deps: mime-db@~1.5.0 | ||
249 | + - Add new mime types | ||
250 | + - Fix various invalid MIME type entries | ||
251 | + | ||
252 | +2.0.6 / 2014-12-30 | ||
253 | +================== | ||
254 | + | ||
255 | + * deps: mime-db@~1.4.0 | ||
256 | + - Add new mime types | ||
257 | + - Fix various invalid MIME type entries | ||
258 | + - Remove example template MIME types | ||
259 | + | ||
260 | +2.0.5 / 2014-12-29 | ||
261 | +================== | ||
262 | + | ||
263 | + * deps: mime-db@~1.3.1 | ||
264 | + - Fix missing extensions | ||
265 | + | ||
266 | +2.0.4 / 2014-12-10 | ||
267 | +================== | ||
268 | + | ||
269 | + * deps: mime-db@~1.3.0 | ||
270 | + - Add new mime types | ||
271 | + | ||
272 | +2.0.3 / 2014-11-09 | ||
273 | +================== | ||
274 | + | ||
275 | + * deps: mime-db@~1.2.0 | ||
276 | + - Add new mime types | ||
277 | + | ||
278 | +2.0.2 / 2014-09-28 | ||
279 | +================== | ||
280 | + | ||
281 | + * deps: mime-db@~1.1.0 | ||
282 | + - Add new mime types | ||
283 | + - Add additional compressible | ||
284 | + - Update charsets | ||
285 | + | ||
286 | +2.0.1 / 2014-09-07 | ||
287 | +================== | ||
288 | + | ||
289 | + * Support Node.js 0.6 | ||
290 | + | ||
291 | +2.0.0 / 2014-09-02 | ||
292 | +================== | ||
293 | + | ||
294 | + * Use `mime-db` | ||
295 | + * Remove `.define()` | ||
296 | + | ||
297 | +1.0.2 / 2014-08-04 | ||
298 | +================== | ||
299 | + | ||
300 | + * Set charset=utf-8 for `text/javascript` | ||
301 | + | ||
302 | +1.0.1 / 2014-06-24 | ||
303 | +================== | ||
304 | + | ||
305 | + * Add `text/jsx` type | ||
306 | + | ||
307 | +1.0.0 / 2014-05-12 | ||
308 | +================== | ||
309 | + | ||
310 | + * Return `false` for unknown types | ||
311 | + * Set charset=utf-8 for `application/json` | ||
312 | + | ||
313 | +0.1.0 / 2014-05-02 | ||
314 | +================== | ||
315 | + | ||
316 | + * Initial release |
1 | +(The MIT License) | ||
2 | + | ||
3 | +Copyright (c) 2014 Jonathan Ong <me@jongleberry.com> | ||
4 | +Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com> | ||
5 | + | ||
6 | +Permission is hereby granted, free of charge, to any person obtaining | ||
7 | +a copy of this software and associated documentation files (the | ||
8 | +'Software'), to deal in the Software without restriction, including | ||
9 | +without limitation the rights to use, copy, modify, merge, publish, | ||
10 | +distribute, sublicense, and/or sell copies of the Software, and to | ||
11 | +permit persons to whom the Software is furnished to do so, subject to | ||
12 | +the following conditions: | ||
13 | + | ||
14 | +The above copyright notice and this permission notice shall be | ||
15 | +included in all copies or substantial portions of the Software. | ||
16 | + | ||
17 | +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
18 | +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
19 | +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
20 | +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
21 | +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
22 | +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
23 | +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
1 | +# mime-types | ||
2 | + | ||
3 | +[![NPM Version][npm-version-image]][npm-url] | ||
4 | +[![NPM Downloads][npm-downloads-image]][npm-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 | +The ultimate javascript content-type utility. | ||
10 | + | ||
11 | +Similar to [the `mime@1.x` module](https://www.npmjs.com/package/mime), except: | ||
12 | + | ||
13 | +- __No fallbacks.__ Instead of naively returning the first available type, | ||
14 | + `mime-types` simply returns `false`, so do | ||
15 | + `var type = mime.lookup('unrecognized') || 'application/octet-stream'`. | ||
16 | +- No `new Mime()` business, so you could do `var lookup = require('mime-types').lookup`. | ||
17 | +- No `.define()` functionality | ||
18 | +- Bug fixes for `.lookup(path)` | ||
19 | + | ||
20 | +Otherwise, the API is compatible with `mime` 1.x. | ||
21 | + | ||
22 | +## Install | ||
23 | + | ||
24 | +This is a [Node.js](https://nodejs.org/en/) module available through the | ||
25 | +[npm registry](https://www.npmjs.com/). Installation is done using the | ||
26 | +[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally): | ||
27 | + | ||
28 | +```sh | ||
29 | +$ npm install mime-types | ||
30 | +``` | ||
31 | + | ||
32 | +## Adding Types | ||
33 | + | ||
34 | +All mime types are based on [mime-db](https://www.npmjs.com/package/mime-db), | ||
35 | +so open a PR there if you'd like to add mime types. | ||
36 | + | ||
37 | +## API | ||
38 | + | ||
39 | +```js | ||
40 | +var mime = require('mime-types') | ||
41 | +``` | ||
42 | + | ||
43 | +All functions return `false` if input is invalid or not found. | ||
44 | + | ||
45 | +### mime.lookup(path) | ||
46 | + | ||
47 | +Lookup the content-type associated with a file. | ||
48 | + | ||
49 | +```js | ||
50 | +mime.lookup('json') // 'application/json' | ||
51 | +mime.lookup('.md') // 'text/markdown' | ||
52 | +mime.lookup('file.html') // 'text/html' | ||
53 | +mime.lookup('folder/file.js') // 'application/javascript' | ||
54 | +mime.lookup('folder/.htaccess') // false | ||
55 | + | ||
56 | +mime.lookup('cats') // false | ||
57 | +``` | ||
58 | + | ||
59 | +### mime.contentType(type) | ||
60 | + | ||
61 | +Create a full content-type header given a content-type or extension. | ||
62 | +When given an extension, `mime.lookup` is used to get the matching | ||
63 | +content-type, otherwise the given content-type is used. Then if the | ||
64 | +content-type does not already have a `charset` parameter, `mime.charset` | ||
65 | +is used to get the default charset and add to the returned content-type. | ||
66 | + | ||
67 | +```js | ||
68 | +mime.contentType('markdown') // 'text/x-markdown; charset=utf-8' | ||
69 | +mime.contentType('file.json') // 'application/json; charset=utf-8' | ||
70 | +mime.contentType('text/html') // 'text/html; charset=utf-8' | ||
71 | +mime.contentType('text/html; charset=iso-8859-1') // 'text/html; charset=iso-8859-1' | ||
72 | + | ||
73 | +// from a full path | ||
74 | +mime.contentType(path.extname('/path/to/file.json')) // 'application/json; charset=utf-8' | ||
75 | +``` | ||
76 | + | ||
77 | +### mime.extension(type) | ||
78 | + | ||
79 | +Get the default extension for a content-type. | ||
80 | + | ||
81 | +```js | ||
82 | +mime.extension('application/octet-stream') // 'bin' | ||
83 | +``` | ||
84 | + | ||
85 | +### mime.charset(type) | ||
86 | + | ||
87 | +Lookup the implied default charset of a content-type. | ||
88 | + | ||
89 | +```js | ||
90 | +mime.charset('text/markdown') // 'UTF-8' | ||
91 | +``` | ||
92 | + | ||
93 | +### var type = mime.types[extension] | ||
94 | + | ||
95 | +A map of content-types by extension. | ||
96 | + | ||
97 | +### [extensions...] = mime.extensions[type] | ||
98 | + | ||
99 | +A map of extensions by content-type. | ||
100 | + | ||
101 | +## License | ||
102 | + | ||
103 | +[MIT](LICENSE) | ||
104 | + | ||
105 | +[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/mime-types/master | ||
106 | +[coveralls-url]: https://coveralls.io/r/jshttp/mime-types?branch=master | ||
107 | +[node-version-image]: https://badgen.net/npm/node/mime-types | ||
108 | +[node-version-url]: https://nodejs.org/en/download | ||
109 | +[npm-downloads-image]: https://badgen.net/npm/dm/mime-types | ||
110 | +[npm-url]: https://npmjs.org/package/mime-types | ||
111 | +[npm-version-image]: https://badgen.net/npm/v/mime-types | ||
112 | +[travis-image]: https://badgen.net/travis/jshttp/mime-types/master | ||
113 | +[travis-url]: https://travis-ci.org/jshttp/mime-types |
1 | +/*! | ||
2 | + * mime-types | ||
3 | + * Copyright(c) 2014 Jonathan Ong | ||
4 | + * Copyright(c) 2015 Douglas Christopher Wilson | ||
5 | + * MIT Licensed | ||
6 | + */ | ||
7 | + | ||
8 | +'use strict' | ||
9 | + | ||
10 | +/** | ||
11 | + * Module dependencies. | ||
12 | + * @private | ||
13 | + */ | ||
14 | + | ||
15 | +var db = require('mime-db') | ||
16 | +var extname = require('path').extname | ||
17 | + | ||
18 | +/** | ||
19 | + * Module variables. | ||
20 | + * @private | ||
21 | + */ | ||
22 | + | ||
23 | +var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/ | ||
24 | +var TEXT_TYPE_REGEXP = /^text\//i | ||
25 | + | ||
26 | +/** | ||
27 | + * Module exports. | ||
28 | + * @public | ||
29 | + */ | ||
30 | + | ||
31 | +exports.charset = charset | ||
32 | +exports.charsets = { lookup: charset } | ||
33 | +exports.contentType = contentType | ||
34 | +exports.extension = extension | ||
35 | +exports.extensions = Object.create(null) | ||
36 | +exports.lookup = lookup | ||
37 | +exports.types = Object.create(null) | ||
38 | + | ||
39 | +// Populate the extensions/types maps | ||
40 | +populateMaps(exports.extensions, exports.types) | ||
41 | + | ||
42 | +/** | ||
43 | + * Get the default charset for a MIME type. | ||
44 | + * | ||
45 | + * @param {string} type | ||
46 | + * @return {boolean|string} | ||
47 | + */ | ||
48 | + | ||
49 | +function charset (type) { | ||
50 | + if (!type || typeof type !== 'string') { | ||
51 | + return false | ||
52 | + } | ||
53 | + | ||
54 | + // TODO: use media-typer | ||
55 | + var match = EXTRACT_TYPE_REGEXP.exec(type) | ||
56 | + var mime = match && db[match[1].toLowerCase()] | ||
57 | + | ||
58 | + if (mime && mime.charset) { | ||
59 | + return mime.charset | ||
60 | + } | ||
61 | + | ||
62 | + // default text/* to utf-8 | ||
63 | + if (match && TEXT_TYPE_REGEXP.test(match[1])) { | ||
64 | + return 'UTF-8' | ||
65 | + } | ||
66 | + | ||
67 | + return false | ||
68 | +} | ||
69 | + | ||
70 | +/** | ||
71 | + * Create a full Content-Type header given a MIME type or extension. | ||
72 | + * | ||
73 | + * @param {string} str | ||
74 | + * @return {boolean|string} | ||
75 | + */ | ||
76 | + | ||
77 | +function contentType (str) { | ||
78 | + // TODO: should this even be in this module? | ||
79 | + if (!str || typeof str !== 'string') { | ||
80 | + return false | ||
81 | + } | ||
82 | + | ||
83 | + var mime = str.indexOf('/') === -1 | ||
84 | + ? exports.lookup(str) | ||
85 | + : str | ||
86 | + | ||
87 | + if (!mime) { | ||
88 | + return false | ||
89 | + } | ||
90 | + | ||
91 | + // TODO: use content-type or other module | ||
92 | + if (mime.indexOf('charset') === -1) { | ||
93 | + var charset = exports.charset(mime) | ||
94 | + if (charset) mime += '; charset=' + charset.toLowerCase() | ||
95 | + } | ||
96 | + | ||
97 | + return mime | ||
98 | +} | ||
99 | + | ||
100 | +/** | ||
101 | + * Get the default extension for a MIME type. | ||
102 | + * | ||
103 | + * @param {string} type | ||
104 | + * @return {boolean|string} | ||
105 | + */ | ||
106 | + | ||
107 | +function extension (type) { | ||
108 | + if (!type || typeof type !== 'string') { | ||
109 | + return false | ||
110 | + } | ||
111 | + | ||
112 | + // TODO: use media-typer | ||
113 | + var match = EXTRACT_TYPE_REGEXP.exec(type) | ||
114 | + | ||
115 | + // get extensions | ||
116 | + var exts = match && exports.extensions[match[1].toLowerCase()] | ||
117 | + | ||
118 | + if (!exts || !exts.length) { | ||
119 | + return false | ||
120 | + } | ||
121 | + | ||
122 | + return exts[0] | ||
123 | +} | ||
124 | + | ||
125 | +/** | ||
126 | + * Lookup the MIME type for a file path/extension. | ||
127 | + * | ||
128 | + * @param {string} path | ||
129 | + * @return {boolean|string} | ||
130 | + */ | ||
131 | + | ||
132 | +function lookup (path) { | ||
133 | + if (!path || typeof path !== 'string') { | ||
134 | + return false | ||
135 | + } | ||
136 | + | ||
137 | + // get the extension ("ext" or ".ext" or full path) | ||
138 | + var extension = extname('x.' + path) | ||
139 | + .toLowerCase() | ||
140 | + .substr(1) | ||
141 | + | ||
142 | + if (!extension) { | ||
143 | + return false | ||
144 | + } | ||
145 | + | ||
146 | + return exports.types[extension] || false | ||
147 | +} | ||
148 | + | ||
149 | +/** | ||
150 | + * Populate the extensions and types maps. | ||
151 | + * @private | ||
152 | + */ | ||
153 | + | ||
154 | +function populateMaps (extensions, types) { | ||
155 | + // source preference (least -> most) | ||
156 | + var preference = ['nginx', 'apache', undefined, 'iana'] | ||
157 | + | ||
158 | + Object.keys(db).forEach(function forEachMimeType (type) { | ||
159 | + var mime = db[type] | ||
160 | + var exts = mime.extensions | ||
161 | + | ||
162 | + if (!exts || !exts.length) { | ||
163 | + return | ||
164 | + } | ||
165 | + | ||
166 | + // mime -> extensions | ||
167 | + extensions[type] = exts | ||
168 | + | ||
169 | + // extension -> mime | ||
170 | + for (var i = 0; i < exts.length; i++) { | ||
171 | + var extension = exts[i] | ||
172 | + | ||
173 | + if (types[extension]) { | ||
174 | + var from = preference.indexOf(db[types[extension]].source) | ||
175 | + var to = preference.indexOf(mime.source) | ||
176 | + | ||
177 | + if (types[extension] !== 'application/octet-stream' && | ||
178 | + (from > to || (from === to && types[extension].substr(0, 12) === 'application/'))) { | ||
179 | + // skip the remapping | ||
180 | + continue | ||
181 | + } | ||
182 | + } | ||
183 | + | ||
184 | + // set the extension -> mime | ||
185 | + types[extension] = type | ||
186 | + } | ||
187 | + }) | ||
188 | +} |
1 | +{ | ||
2 | + "_args": [ | ||
3 | + [ | ||
4 | + "mime-types@2.1.25", | ||
5 | + "/Users/star/Desktop/YTMT" | ||
6 | + ] | ||
7 | + ], | ||
8 | + "_from": "mime-types@2.1.25", | ||
9 | + "_id": "mime-types@2.1.25", | ||
10 | + "_inBundle": false, | ||
11 | + "_integrity": "sha512-5KhStqB5xpTAeGqKBAMgwaYMnQik7teQN4IAzC7npDv6kzeU6prfkR67bc87J1kWMPGkoaZSq1npmexMgkmEVg==", | ||
12 | + "_location": "/body-parser/mime-types", | ||
13 | + "_phantomChildren": {}, | ||
14 | + "_requested": { | ||
15 | + "type": "version", | ||
16 | + "registry": true, | ||
17 | + "raw": "mime-types@2.1.25", | ||
18 | + "name": "mime-types", | ||
19 | + "escapedName": "mime-types", | ||
20 | + "rawSpec": "2.1.25", | ||
21 | + "saveSpec": null, | ||
22 | + "fetchSpec": "2.1.25" | ||
23 | + }, | ||
24 | + "_requiredBy": [ | ||
25 | + "/body-parser/type-is" | ||
26 | + ], | ||
27 | + "_resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.25.tgz", | ||
28 | + "_spec": "2.1.25", | ||
29 | + "_where": "/Users/star/Desktop/YTMT", | ||
30 | + "bugs": { | ||
31 | + "url": "https://github.com/jshttp/mime-types/issues" | ||
32 | + }, | ||
33 | + "contributors": [ | ||
34 | + { | ||
35 | + "name": "Douglas Christopher Wilson", | ||
36 | + "email": "doug@somethingdoug.com" | ||
37 | + }, | ||
38 | + { | ||
39 | + "name": "Jeremiah Senkpiel", | ||
40 | + "email": "fishrock123@rocketmail.com", | ||
41 | + "url": "https://searchbeam.jit.su" | ||
42 | + }, | ||
43 | + { | ||
44 | + "name": "Jonathan Ong", | ||
45 | + "email": "me@jongleberry.com", | ||
46 | + "url": "http://jongleberry.com" | ||
47 | + } | ||
48 | + ], | ||
49 | + "dependencies": { | ||
50 | + "mime-db": "1.42.0" | ||
51 | + }, | ||
52 | + "description": "The ultimate javascript content-type utility.", | ||
53 | + "devDependencies": { | ||
54 | + "eslint": "6.6.0", | ||
55 | + "eslint-config-standard": "14.1.0", | ||
56 | + "eslint-plugin-import": "2.18.2", | ||
57 | + "eslint-plugin-node": "10.0.0", | ||
58 | + "eslint-plugin-promise": "4.2.1", | ||
59 | + "eslint-plugin-standard": "4.0.1", | ||
60 | + "mocha": "6.2.2", | ||
61 | + "nyc": "14.1.1" | ||
62 | + }, | ||
63 | + "engines": { | ||
64 | + "node": ">= 0.6" | ||
65 | + }, | ||
66 | + "files": [ | ||
67 | + "HISTORY.md", | ||
68 | + "LICENSE", | ||
69 | + "index.js" | ||
70 | + ], | ||
71 | + "homepage": "https://github.com/jshttp/mime-types#readme", | ||
72 | + "keywords": [ | ||
73 | + "mime", | ||
74 | + "types" | ||
75 | + ], | ||
76 | + "license": "MIT", | ||
77 | + "name": "mime-types", | ||
78 | + "repository": { | ||
79 | + "type": "git", | ||
80 | + "url": "git+https://github.com/jshttp/mime-types.git" | ||
81 | + }, | ||
82 | + "scripts": { | ||
83 | + "lint": "eslint .", | ||
84 | + "test": "mocha --reporter spec test/test.js", | ||
85 | + "test-cov": "nyc --reporter=html --reporter=text npm test", | ||
86 | + "test-travis": "nyc --reporter=text npm test" | ||
87 | + }, | ||
88 | + "version": "2.1.25" | ||
89 | +} |
1 | +root = true | ||
2 | + | ||
3 | +[*] | ||
4 | +indent_style = space | ||
5 | +indent_size = 4 | ||
6 | +end_of_line = lf | ||
7 | +charset = utf-8 | ||
8 | +trim_trailing_whitespace = true | ||
9 | +insert_final_newline = true | ||
10 | +max_line_length = 160 | ||
11 | + | ||
12 | +[test/*] | ||
13 | +max_line_length = off | ||
14 | + | ||
15 | +[*.md] | ||
16 | +max_line_length = off | ||
17 | + | ||
18 | +[*.json] | ||
19 | +max_line_length = off | ||
20 | + | ||
21 | +[Makefile] | ||
22 | +max_line_length = off | ||
23 | + | ||
24 | +[CHANGELOG.md] | ||
25 | +indent_style = space | ||
26 | +indent_size = 2 | ||
27 | + | ||
28 | +[LICENSE] | ||
29 | +indent_size = 2 | ||
30 | +max_line_length = off |
1 | +dist |
1 | +{ | ||
2 | + "root": true, | ||
3 | + | ||
4 | + "extends": "@ljharb", | ||
5 | + | ||
6 | + "rules": { | ||
7 | + "complexity": 0, | ||
8 | + "consistent-return": 1, | ||
9 | + "func-name-matching": 0, | ||
10 | + "id-length": [2, { "min": 1, "max": 25, "properties": "never" }], | ||
11 | + "indent": [2, 4], | ||
12 | + "max-lines-per-function": [2, { "max": 150 }], | ||
13 | + "max-params": [2, 14], | ||
14 | + "max-statements": [2, 52], | ||
15 | + "multiline-comment-style": 0, | ||
16 | + "no-continue": 1, | ||
17 | + "no-magic-numbers": 0, | ||
18 | + "no-restricted-syntax": [2, "BreakStatement", "DebuggerStatement", "ForInStatement", "LabeledStatement", "WithStatement"], | ||
19 | + "operator-linebreak": [2, "before"], | ||
20 | + } | ||
21 | +} |
This diff is collapsed. Click to expand it.
1 | +Copyright (c) 2014 Nathan LaFreniere and other contributors. | ||
2 | +All rights reserved. | ||
3 | + | ||
4 | +Redistribution and use in source and binary forms, with or without | ||
5 | +modification, are permitted provided that the following conditions are met: | ||
6 | + * Redistributions of source code must retain the above copyright | ||
7 | + notice, this list of conditions and the following disclaimer. | ||
8 | + * Redistributions in binary form must reproduce the above copyright | ||
9 | + notice, this list of conditions and the following disclaimer in the | ||
10 | + documentation and/or other materials provided with the distribution. | ||
11 | + * The names of any contributors may not be used to endorse or promote | ||
12 | + products derived from this software without specific prior written | ||
13 | + permission. | ||
14 | + | ||
15 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
16 | +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
17 | +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
18 | +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY | ||
19 | +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
20 | +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
21 | +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
22 | +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | + | ||
26 | + * * * | ||
27 | + | ||
28 | +The complete list of contributors can be found at: https://github.com/hapijs/qs/graphs/contributors |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 | +'use strict'; | ||
2 | + | ||
3 | +var replace = String.prototype.replace; | ||
4 | +var percentTwenties = /%20/g; | ||
5 | + | ||
6 | +module.exports = { | ||
7 | + 'default': 'RFC3986', | ||
8 | + formatters: { | ||
9 | + RFC1738: function (value) { | ||
10 | + return replace.call(value, percentTwenties, '+'); | ||
11 | + }, | ||
12 | + RFC3986: function (value) { | ||
13 | + return value; | ||
14 | + } | ||
15 | + }, | ||
16 | + RFC1738: 'RFC1738', | ||
17 | + RFC3986: 'RFC3986' | ||
18 | +}; |
1 | +'use strict'; | ||
2 | + | ||
3 | +var utils = require('./utils'); | ||
4 | + | ||
5 | +var has = Object.prototype.hasOwnProperty; | ||
6 | + | ||
7 | +var defaults = { | ||
8 | + allowDots: false, | ||
9 | + allowPrototypes: false, | ||
10 | + arrayLimit: 20, | ||
11 | + charset: 'utf-8', | ||
12 | + charsetSentinel: false, | ||
13 | + comma: false, | ||
14 | + decoder: utils.decode, | ||
15 | + delimiter: '&', | ||
16 | + depth: 5, | ||
17 | + ignoreQueryPrefix: false, | ||
18 | + interpretNumericEntities: false, | ||
19 | + parameterLimit: 1000, | ||
20 | + parseArrays: true, | ||
21 | + plainObjects: false, | ||
22 | + strictNullHandling: false | ||
23 | +}; | ||
24 | + | ||
25 | +var interpretNumericEntities = function (str) { | ||
26 | + return str.replace(/&#(\d+);/g, function ($0, numberStr) { | ||
27 | + return String.fromCharCode(parseInt(numberStr, 10)); | ||
28 | + }); | ||
29 | +}; | ||
30 | + | ||
31 | +// This is what browsers will submit when the ✓ character occurs in an | ||
32 | +// application/x-www-form-urlencoded body and the encoding of the page containing | ||
33 | +// the form is iso-8859-1, or when the submitted form has an accept-charset | ||
34 | +// attribute of iso-8859-1. Presumably also with other charsets that do not contain | ||
35 | +// the ✓ character, such as us-ascii. | ||
36 | +var isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('✓') | ||
37 | + | ||
38 | +// These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded. | ||
39 | +var charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('✓') | ||
40 | + | ||
41 | +var parseValues = function parseQueryStringValues(str, options) { | ||
42 | + var obj = {}; | ||
43 | + var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str; | ||
44 | + var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit; | ||
45 | + var parts = cleanStr.split(options.delimiter, limit); | ||
46 | + var skipIndex = -1; // Keep track of where the utf8 sentinel was found | ||
47 | + var i; | ||
48 | + | ||
49 | + var charset = options.charset; | ||
50 | + if (options.charsetSentinel) { | ||
51 | + for (i = 0; i < parts.length; ++i) { | ||
52 | + if (parts[i].indexOf('utf8=') === 0) { | ||
53 | + if (parts[i] === charsetSentinel) { | ||
54 | + charset = 'utf-8'; | ||
55 | + } else if (parts[i] === isoSentinel) { | ||
56 | + charset = 'iso-8859-1'; | ||
57 | + } | ||
58 | + skipIndex = i; | ||
59 | + i = parts.length; // The eslint settings do not allow break; | ||
60 | + } | ||
61 | + } | ||
62 | + } | ||
63 | + | ||
64 | + for (i = 0; i < parts.length; ++i) { | ||
65 | + if (i === skipIndex) { | ||
66 | + continue; | ||
67 | + } | ||
68 | + var part = parts[i]; | ||
69 | + | ||
70 | + var bracketEqualsPos = part.indexOf(']='); | ||
71 | + var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1; | ||
72 | + | ||
73 | + var key, val; | ||
74 | + if (pos === -1) { | ||
75 | + key = options.decoder(part, defaults.decoder, charset); | ||
76 | + val = options.strictNullHandling ? null : ''; | ||
77 | + } else { | ||
78 | + key = options.decoder(part.slice(0, pos), defaults.decoder, charset); | ||
79 | + val = options.decoder(part.slice(pos + 1), defaults.decoder, charset); | ||
80 | + } | ||
81 | + | ||
82 | + if (val && options.interpretNumericEntities && charset === 'iso-8859-1') { | ||
83 | + val = interpretNumericEntities(val); | ||
84 | + } | ||
85 | + | ||
86 | + if (val && options.comma && val.indexOf(',') > -1) { | ||
87 | + val = val.split(','); | ||
88 | + } | ||
89 | + | ||
90 | + if (has.call(obj, key)) { | ||
91 | + obj[key] = utils.combine(obj[key], val); | ||
92 | + } else { | ||
93 | + obj[key] = val; | ||
94 | + } | ||
95 | + } | ||
96 | + | ||
97 | + return obj; | ||
98 | +}; | ||
99 | + | ||
100 | +var parseObject = function (chain, val, options) { | ||
101 | + var leaf = val; | ||
102 | + | ||
103 | + for (var i = chain.length - 1; i >= 0; --i) { | ||
104 | + var obj; | ||
105 | + var root = chain[i]; | ||
106 | + | ||
107 | + if (root === '[]' && options.parseArrays) { | ||
108 | + obj = [].concat(leaf); | ||
109 | + } else { | ||
110 | + obj = options.plainObjects ? Object.create(null) : {}; | ||
111 | + var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root; | ||
112 | + var index = parseInt(cleanRoot, 10); | ||
113 | + if (!options.parseArrays && cleanRoot === '') { | ||
114 | + obj = { 0: leaf }; | ||
115 | + } else if ( | ||
116 | + !isNaN(index) | ||
117 | + && root !== cleanRoot | ||
118 | + && String(index) === cleanRoot | ||
119 | + && index >= 0 | ||
120 | + && (options.parseArrays && index <= options.arrayLimit) | ||
121 | + ) { | ||
122 | + obj = []; | ||
123 | + obj[index] = leaf; | ||
124 | + } else { | ||
125 | + obj[cleanRoot] = leaf; | ||
126 | + } | ||
127 | + } | ||
128 | + | ||
129 | + leaf = obj; | ||
130 | + } | ||
131 | + | ||
132 | + return leaf; | ||
133 | +}; | ||
134 | + | ||
135 | +var parseKeys = function parseQueryStringKeys(givenKey, val, options) { | ||
136 | + if (!givenKey) { | ||
137 | + return; | ||
138 | + } | ||
139 | + | ||
140 | + // Transform dot notation to bracket notation | ||
141 | + var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey; | ||
142 | + | ||
143 | + // The regex chunks | ||
144 | + | ||
145 | + var brackets = /(\[[^[\]]*])/; | ||
146 | + var child = /(\[[^[\]]*])/g; | ||
147 | + | ||
148 | + // Get the parent | ||
149 | + | ||
150 | + var segment = brackets.exec(key); | ||
151 | + var parent = segment ? key.slice(0, segment.index) : key; | ||
152 | + | ||
153 | + // Stash the parent if it exists | ||
154 | + | ||
155 | + var keys = []; | ||
156 | + if (parent) { | ||
157 | + // If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties | ||
158 | + if (!options.plainObjects && has.call(Object.prototype, parent)) { | ||
159 | + if (!options.allowPrototypes) { | ||
160 | + return; | ||
161 | + } | ||
162 | + } | ||
163 | + | ||
164 | + keys.push(parent); | ||
165 | + } | ||
166 | + | ||
167 | + // Loop through children appending to the array until we hit depth | ||
168 | + | ||
169 | + var i = 0; | ||
170 | + while ((segment = child.exec(key)) !== null && i < options.depth) { | ||
171 | + i += 1; | ||
172 | + if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) { | ||
173 | + if (!options.allowPrototypes) { | ||
174 | + return; | ||
175 | + } | ||
176 | + } | ||
177 | + keys.push(segment[1]); | ||
178 | + } | ||
179 | + | ||
180 | + // If there's a remainder, just add whatever is left | ||
181 | + | ||
182 | + if (segment) { | ||
183 | + keys.push('[' + key.slice(segment.index) + ']'); | ||
184 | + } | ||
185 | + | ||
186 | + return parseObject(keys, val, options); | ||
187 | +}; | ||
188 | + | ||
189 | +var normalizeParseOptions = function normalizeParseOptions(opts) { | ||
190 | + if (!opts) { | ||
191 | + return defaults; | ||
192 | + } | ||
193 | + | ||
194 | + if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') { | ||
195 | + throw new TypeError('Decoder has to be a function.'); | ||
196 | + } | ||
197 | + | ||
198 | + if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') { | ||
199 | + throw new Error('The charset option must be either utf-8, iso-8859-1, or undefined'); | ||
200 | + } | ||
201 | + var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset; | ||
202 | + | ||
203 | + return { | ||
204 | + allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots, | ||
205 | + allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes, | ||
206 | + arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit, | ||
207 | + charset: charset, | ||
208 | + charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel, | ||
209 | + comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma, | ||
210 | + decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder, | ||
211 | + delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter, | ||
212 | + depth: typeof opts.depth === 'number' ? opts.depth : defaults.depth, | ||
213 | + ignoreQueryPrefix: opts.ignoreQueryPrefix === true, | ||
214 | + interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities, | ||
215 | + parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit, | ||
216 | + parseArrays: opts.parseArrays !== false, | ||
217 | + plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects, | ||
218 | + strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling | ||
219 | + }; | ||
220 | +}; | ||
221 | + | ||
222 | +module.exports = function (str, opts) { | ||
223 | + var options = normalizeParseOptions(opts); | ||
224 | + | ||
225 | + if (str === '' || str === null || typeof str === 'undefined') { | ||
226 | + return options.plainObjects ? Object.create(null) : {}; | ||
227 | + } | ||
228 | + | ||
229 | + var tempObj = typeof str === 'string' ? parseValues(str, options) : str; | ||
230 | + var obj = options.plainObjects ? Object.create(null) : {}; | ||
231 | + | ||
232 | + // Iterate over the keys and setup the new object | ||
233 | + | ||
234 | + var keys = Object.keys(tempObj); | ||
235 | + for (var i = 0; i < keys.length; ++i) { | ||
236 | + var key = keys[i]; | ||
237 | + var newObj = parseKeys(key, tempObj[key], options); | ||
238 | + obj = utils.merge(obj, newObj, options); | ||
239 | + } | ||
240 | + | ||
241 | + return utils.compact(obj); | ||
242 | +}; |
1 | +'use strict'; | ||
2 | + | ||
3 | +var utils = require('./utils'); | ||
4 | +var formats = require('./formats'); | ||
5 | +var has = Object.prototype.hasOwnProperty; | ||
6 | + | ||
7 | +var arrayPrefixGenerators = { | ||
8 | + brackets: function brackets(prefix) { // eslint-disable-line func-name-matching | ||
9 | + return prefix + '[]'; | ||
10 | + }, | ||
11 | + comma: 'comma', | ||
12 | + indices: function indices(prefix, key) { // eslint-disable-line func-name-matching | ||
13 | + return prefix + '[' + key + ']'; | ||
14 | + }, | ||
15 | + repeat: function repeat(prefix) { // eslint-disable-line func-name-matching | ||
16 | + return prefix; | ||
17 | + } | ||
18 | +}; | ||
19 | + | ||
20 | +var isArray = Array.isArray; | ||
21 | +var push = Array.prototype.push; | ||
22 | +var pushToArray = function (arr, valueOrArray) { | ||
23 | + push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]); | ||
24 | +}; | ||
25 | + | ||
26 | +var toISO = Date.prototype.toISOString; | ||
27 | + | ||
28 | +var defaults = { | ||
29 | + addQueryPrefix: false, | ||
30 | + allowDots: false, | ||
31 | + charset: 'utf-8', | ||
32 | + charsetSentinel: false, | ||
33 | + delimiter: '&', | ||
34 | + encode: true, | ||
35 | + encoder: utils.encode, | ||
36 | + encodeValuesOnly: false, | ||
37 | + formatter: formats.formatters[formats['default']], | ||
38 | + // deprecated | ||
39 | + indices: false, | ||
40 | + serializeDate: function serializeDate(date) { // eslint-disable-line func-name-matching | ||
41 | + return toISO.call(date); | ||
42 | + }, | ||
43 | + skipNulls: false, | ||
44 | + strictNullHandling: false | ||
45 | +}; | ||
46 | + | ||
47 | +var stringify = function stringify( // eslint-disable-line func-name-matching | ||
48 | + object, | ||
49 | + prefix, | ||
50 | + generateArrayPrefix, | ||
51 | + strictNullHandling, | ||
52 | + skipNulls, | ||
53 | + encoder, | ||
54 | + filter, | ||
55 | + sort, | ||
56 | + allowDots, | ||
57 | + serializeDate, | ||
58 | + formatter, | ||
59 | + encodeValuesOnly, | ||
60 | + charset | ||
61 | +) { | ||
62 | + var obj = object; | ||
63 | + if (typeof filter === 'function') { | ||
64 | + obj = filter(prefix, obj); | ||
65 | + } else if (obj instanceof Date) { | ||
66 | + obj = serializeDate(obj); | ||
67 | + } else if (generateArrayPrefix === 'comma' && isArray(obj)) { | ||
68 | + obj = obj.join(','); | ||
69 | + } | ||
70 | + | ||
71 | + if (obj === null) { | ||
72 | + if (strictNullHandling) { | ||
73 | + return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset) : prefix; | ||
74 | + } | ||
75 | + | ||
76 | + obj = ''; | ||
77 | + } | ||
78 | + | ||
79 | + if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || utils.isBuffer(obj)) { | ||
80 | + if (encoder) { | ||
81 | + var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset); | ||
82 | + return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset))]; | ||
83 | + } | ||
84 | + return [formatter(prefix) + '=' + formatter(String(obj))]; | ||
85 | + } | ||
86 | + | ||
87 | + var values = []; | ||
88 | + | ||
89 | + if (typeof obj === 'undefined') { | ||
90 | + return values; | ||
91 | + } | ||
92 | + | ||
93 | + var objKeys; | ||
94 | + if (isArray(filter)) { | ||
95 | + objKeys = filter; | ||
96 | + } else { | ||
97 | + var keys = Object.keys(obj); | ||
98 | + objKeys = sort ? keys.sort(sort) : keys; | ||
99 | + } | ||
100 | + | ||
101 | + for (var i = 0; i < objKeys.length; ++i) { | ||
102 | + var key = objKeys[i]; | ||
103 | + | ||
104 | + if (skipNulls && obj[key] === null) { | ||
105 | + continue; | ||
106 | + } | ||
107 | + | ||
108 | + if (isArray(obj)) { | ||
109 | + pushToArray(values, stringify( | ||
110 | + obj[key], | ||
111 | + typeof generateArrayPrefix === 'function' ? generateArrayPrefix(prefix, key) : prefix, | ||
112 | + generateArrayPrefix, | ||
113 | + strictNullHandling, | ||
114 | + skipNulls, | ||
115 | + encoder, | ||
116 | + filter, | ||
117 | + sort, | ||
118 | + allowDots, | ||
119 | + serializeDate, | ||
120 | + formatter, | ||
121 | + encodeValuesOnly, | ||
122 | + charset | ||
123 | + )); | ||
124 | + } else { | ||
125 | + pushToArray(values, stringify( | ||
126 | + obj[key], | ||
127 | + prefix + (allowDots ? '.' + key : '[' + key + ']'), | ||
128 | + generateArrayPrefix, | ||
129 | + strictNullHandling, | ||
130 | + skipNulls, | ||
131 | + encoder, | ||
132 | + filter, | ||
133 | + sort, | ||
134 | + allowDots, | ||
135 | + serializeDate, | ||
136 | + formatter, | ||
137 | + encodeValuesOnly, | ||
138 | + charset | ||
139 | + )); | ||
140 | + } | ||
141 | + } | ||
142 | + | ||
143 | + return values; | ||
144 | +}; | ||
145 | + | ||
146 | +var normalizeStringifyOptions = function normalizeStringifyOptions(opts) { | ||
147 | + if (!opts) { | ||
148 | + return defaults; | ||
149 | + } | ||
150 | + | ||
151 | + if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') { | ||
152 | + throw new TypeError('Encoder has to be a function.'); | ||
153 | + } | ||
154 | + | ||
155 | + var charset = opts.charset || defaults.charset; | ||
156 | + if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') { | ||
157 | + throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined'); | ||
158 | + } | ||
159 | + | ||
160 | + var format = formats['default']; | ||
161 | + if (typeof opts.format !== 'undefined') { | ||
162 | + if (!has.call(formats.formatters, opts.format)) { | ||
163 | + throw new TypeError('Unknown format option provided.'); | ||
164 | + } | ||
165 | + format = opts.format; | ||
166 | + } | ||
167 | + var formatter = formats.formatters[format]; | ||
168 | + | ||
169 | + var filter = defaults.filter; | ||
170 | + if (typeof opts.filter === 'function' || isArray(opts.filter)) { | ||
171 | + filter = opts.filter; | ||
172 | + } | ||
173 | + | ||
174 | + return { | ||
175 | + addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix, | ||
176 | + allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots, | ||
177 | + charset: charset, | ||
178 | + charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel, | ||
179 | + delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter, | ||
180 | + encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode, | ||
181 | + encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder, | ||
182 | + encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly, | ||
183 | + filter: filter, | ||
184 | + formatter: formatter, | ||
185 | + serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate, | ||
186 | + skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls, | ||
187 | + sort: typeof opts.sort === 'function' ? opts.sort : null, | ||
188 | + strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling | ||
189 | + }; | ||
190 | +}; | ||
191 | + | ||
192 | +module.exports = function (object, opts) { | ||
193 | + var obj = object; | ||
194 | + var options = normalizeStringifyOptions(opts); | ||
195 | + | ||
196 | + var objKeys; | ||
197 | + var filter; | ||
198 | + | ||
199 | + if (typeof options.filter === 'function') { | ||
200 | + filter = options.filter; | ||
201 | + obj = filter('', obj); | ||
202 | + } else if (isArray(options.filter)) { | ||
203 | + filter = options.filter; | ||
204 | + objKeys = filter; | ||
205 | + } | ||
206 | + | ||
207 | + var keys = []; | ||
208 | + | ||
209 | + if (typeof obj !== 'object' || obj === null) { | ||
210 | + return ''; | ||
211 | + } | ||
212 | + | ||
213 | + var arrayFormat; | ||
214 | + if (opts && opts.arrayFormat in arrayPrefixGenerators) { | ||
215 | + arrayFormat = opts.arrayFormat; | ||
216 | + } else if (opts && 'indices' in opts) { | ||
217 | + arrayFormat = opts.indices ? 'indices' : 'repeat'; | ||
218 | + } else { | ||
219 | + arrayFormat = 'indices'; | ||
220 | + } | ||
221 | + | ||
222 | + var generateArrayPrefix = arrayPrefixGenerators[arrayFormat]; | ||
223 | + | ||
224 | + if (!objKeys) { | ||
225 | + objKeys = Object.keys(obj); | ||
226 | + } | ||
227 | + | ||
228 | + if (options.sort) { | ||
229 | + objKeys.sort(options.sort); | ||
230 | + } | ||
231 | + | ||
232 | + for (var i = 0; i < objKeys.length; ++i) { | ||
233 | + var key = objKeys[i]; | ||
234 | + | ||
235 | + if (options.skipNulls && obj[key] === null) { | ||
236 | + continue; | ||
237 | + } | ||
238 | + pushToArray(keys, stringify( | ||
239 | + obj[key], | ||
240 | + key, | ||
241 | + generateArrayPrefix, | ||
242 | + options.strictNullHandling, | ||
243 | + options.skipNulls, | ||
244 | + options.encode ? options.encoder : null, | ||
245 | + options.filter, | ||
246 | + options.sort, | ||
247 | + options.allowDots, | ||
248 | + options.serializeDate, | ||
249 | + options.formatter, | ||
250 | + options.encodeValuesOnly, | ||
251 | + options.charset | ||
252 | + )); | ||
253 | + } | ||
254 | + | ||
255 | + var joined = keys.join(options.delimiter); | ||
256 | + var prefix = options.addQueryPrefix === true ? '?' : ''; | ||
257 | + | ||
258 | + if (options.charsetSentinel) { | ||
259 | + if (options.charset === 'iso-8859-1') { | ||
260 | + // encodeURIComponent('✓'), the "numeric entity" representation of a checkmark | ||
261 | + prefix += 'utf8=%26%2310003%3B&'; | ||
262 | + } else { | ||
263 | + // encodeURIComponent('✓') | ||
264 | + prefix += 'utf8=%E2%9C%93&'; | ||
265 | + } | ||
266 | + } | ||
267 | + | ||
268 | + return joined.length > 0 ? prefix + joined : ''; | ||
269 | +}; |
1 | +'use strict'; | ||
2 | + | ||
3 | +var has = Object.prototype.hasOwnProperty; | ||
4 | +var isArray = Array.isArray; | ||
5 | + | ||
6 | +var hexTable = (function () { | ||
7 | + var array = []; | ||
8 | + for (var i = 0; i < 256; ++i) { | ||
9 | + array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase()); | ||
10 | + } | ||
11 | + | ||
12 | + return array; | ||
13 | +}()); | ||
14 | + | ||
15 | +var compactQueue = function compactQueue(queue) { | ||
16 | + while (queue.length > 1) { | ||
17 | + var item = queue.pop(); | ||
18 | + var obj = item.obj[item.prop]; | ||
19 | + | ||
20 | + if (isArray(obj)) { | ||
21 | + var compacted = []; | ||
22 | + | ||
23 | + for (var j = 0; j < obj.length; ++j) { | ||
24 | + if (typeof obj[j] !== 'undefined') { | ||
25 | + compacted.push(obj[j]); | ||
26 | + } | ||
27 | + } | ||
28 | + | ||
29 | + item.obj[item.prop] = compacted; | ||
30 | + } | ||
31 | + } | ||
32 | +}; | ||
33 | + | ||
34 | +var arrayToObject = function arrayToObject(source, options) { | ||
35 | + var obj = options && options.plainObjects ? Object.create(null) : {}; | ||
36 | + for (var i = 0; i < source.length; ++i) { | ||
37 | + if (typeof source[i] !== 'undefined') { | ||
38 | + obj[i] = source[i]; | ||
39 | + } | ||
40 | + } | ||
41 | + | ||
42 | + return obj; | ||
43 | +}; | ||
44 | + | ||
45 | +var merge = function merge(target, source, options) { | ||
46 | + if (!source) { | ||
47 | + return target; | ||
48 | + } | ||
49 | + | ||
50 | + if (typeof source !== 'object') { | ||
51 | + if (isArray(target)) { | ||
52 | + target.push(source); | ||
53 | + } else if (target && typeof target === 'object') { | ||
54 | + if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) { | ||
55 | + target[source] = true; | ||
56 | + } | ||
57 | + } else { | ||
58 | + return [target, source]; | ||
59 | + } | ||
60 | + | ||
61 | + return target; | ||
62 | + } | ||
63 | + | ||
64 | + if (!target || typeof target !== 'object') { | ||
65 | + return [target].concat(source); | ||
66 | + } | ||
67 | + | ||
68 | + var mergeTarget = target; | ||
69 | + if (isArray(target) && !isArray(source)) { | ||
70 | + mergeTarget = arrayToObject(target, options); | ||
71 | + } | ||
72 | + | ||
73 | + if (isArray(target) && isArray(source)) { | ||
74 | + source.forEach(function (item, i) { | ||
75 | + if (has.call(target, i)) { | ||
76 | + var targetItem = target[i]; | ||
77 | + if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') { | ||
78 | + target[i] = merge(targetItem, item, options); | ||
79 | + } else { | ||
80 | + target.push(item); | ||
81 | + } | ||
82 | + } else { | ||
83 | + target[i] = item; | ||
84 | + } | ||
85 | + }); | ||
86 | + return target; | ||
87 | + } | ||
88 | + | ||
89 | + return Object.keys(source).reduce(function (acc, key) { | ||
90 | + var value = source[key]; | ||
91 | + | ||
92 | + if (has.call(acc, key)) { | ||
93 | + acc[key] = merge(acc[key], value, options); | ||
94 | + } else { | ||
95 | + acc[key] = value; | ||
96 | + } | ||
97 | + return acc; | ||
98 | + }, mergeTarget); | ||
99 | +}; | ||
100 | + | ||
101 | +var assign = function assignSingleSource(target, source) { | ||
102 | + return Object.keys(source).reduce(function (acc, key) { | ||
103 | + acc[key] = source[key]; | ||
104 | + return acc; | ||
105 | + }, target); | ||
106 | +}; | ||
107 | + | ||
108 | +var decode = function (str, decoder, charset) { | ||
109 | + var strWithoutPlus = str.replace(/\+/g, ' '); | ||
110 | + if (charset === 'iso-8859-1') { | ||
111 | + // unescape never throws, no try...catch needed: | ||
112 | + return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape); | ||
113 | + } | ||
114 | + // utf-8 | ||
115 | + try { | ||
116 | + return decodeURIComponent(strWithoutPlus); | ||
117 | + } catch (e) { | ||
118 | + return strWithoutPlus; | ||
119 | + } | ||
120 | +}; | ||
121 | + | ||
122 | +var encode = function encode(str, defaultEncoder, charset) { | ||
123 | + // This code was originally written by Brian White (mscdex) for the io.js core querystring library. | ||
124 | + // It has been adapted here for stricter adherence to RFC 3986 | ||
125 | + if (str.length === 0) { | ||
126 | + return str; | ||
127 | + } | ||
128 | + | ||
129 | + var string = typeof str === 'string' ? str : String(str); | ||
130 | + | ||
131 | + if (charset === 'iso-8859-1') { | ||
132 | + return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) { | ||
133 | + return '%26%23' + parseInt($0.slice(2), 16) + '%3B'; | ||
134 | + }); | ||
135 | + } | ||
136 | + | ||
137 | + var out = ''; | ||
138 | + for (var i = 0; i < string.length; ++i) { | ||
139 | + var c = string.charCodeAt(i); | ||
140 | + | ||
141 | + if ( | ||
142 | + c === 0x2D // - | ||
143 | + || c === 0x2E // . | ||
144 | + || c === 0x5F // _ | ||
145 | + || c === 0x7E // ~ | ||
146 | + || (c >= 0x30 && c <= 0x39) // 0-9 | ||
147 | + || (c >= 0x41 && c <= 0x5A) // a-z | ||
148 | + || (c >= 0x61 && c <= 0x7A) // A-Z | ||
149 | + ) { | ||
150 | + out += string.charAt(i); | ||
151 | + continue; | ||
152 | + } | ||
153 | + | ||
154 | + if (c < 0x80) { | ||
155 | + out = out + hexTable[c]; | ||
156 | + continue; | ||
157 | + } | ||
158 | + | ||
159 | + if (c < 0x800) { | ||
160 | + out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]); | ||
161 | + continue; | ||
162 | + } | ||
163 | + | ||
164 | + if (c < 0xD800 || c >= 0xE000) { | ||
165 | + out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]); | ||
166 | + continue; | ||
167 | + } | ||
168 | + | ||
169 | + i += 1; | ||
170 | + c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF)); | ||
171 | + out += hexTable[0xF0 | (c >> 18)] | ||
172 | + + hexTable[0x80 | ((c >> 12) & 0x3F)] | ||
173 | + + hexTable[0x80 | ((c >> 6) & 0x3F)] | ||
174 | + + hexTable[0x80 | (c & 0x3F)]; | ||
175 | + } | ||
176 | + | ||
177 | + return out; | ||
178 | +}; | ||
179 | + | ||
180 | +var compact = function compact(value) { | ||
181 | + var queue = [{ obj: { o: value }, prop: 'o' }]; | ||
182 | + var refs = []; | ||
183 | + | ||
184 | + for (var i = 0; i < queue.length; ++i) { | ||
185 | + var item = queue[i]; | ||
186 | + var obj = item.obj[item.prop]; | ||
187 | + | ||
188 | + var keys = Object.keys(obj); | ||
189 | + for (var j = 0; j < keys.length; ++j) { | ||
190 | + var key = keys[j]; | ||
191 | + var val = obj[key]; | ||
192 | + if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) { | ||
193 | + queue.push({ obj: obj, prop: key }); | ||
194 | + refs.push(val); | ||
195 | + } | ||
196 | + } | ||
197 | + } | ||
198 | + | ||
199 | + compactQueue(queue); | ||
200 | + | ||
201 | + return value; | ||
202 | +}; | ||
203 | + | ||
204 | +var isRegExp = function isRegExp(obj) { | ||
205 | + return Object.prototype.toString.call(obj) === '[object RegExp]'; | ||
206 | +}; | ||
207 | + | ||
208 | +var isBuffer = function isBuffer(obj) { | ||
209 | + if (!obj || typeof obj !== 'object') { | ||
210 | + return false; | ||
211 | + } | ||
212 | + | ||
213 | + return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj)); | ||
214 | +}; | ||
215 | + | ||
216 | +var combine = function combine(a, b) { | ||
217 | + return [].concat(a, b); | ||
218 | +}; | ||
219 | + | ||
220 | +module.exports = { | ||
221 | + arrayToObject: arrayToObject, | ||
222 | + assign: assign, | ||
223 | + combine: combine, | ||
224 | + compact: compact, | ||
225 | + decode: decode, | ||
226 | + encode: encode, | ||
227 | + isBuffer: isBuffer, | ||
228 | + isRegExp: isRegExp, | ||
229 | + merge: merge | ||
230 | +}; |
1 | +{ | ||
2 | + "_args": [ | ||
3 | + [ | ||
4 | + "qs@6.7.0", | ||
5 | + "/Users/star/Desktop/YTMT" | ||
6 | + ] | ||
7 | + ], | ||
8 | + "_from": "qs@6.7.0", | ||
9 | + "_id": "qs@6.7.0", | ||
10 | + "_inBundle": false, | ||
11 | + "_integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", | ||
12 | + "_location": "/body-parser/qs", | ||
13 | + "_phantomChildren": {}, | ||
14 | + "_requested": { | ||
15 | + "type": "version", | ||
16 | + "registry": true, | ||
17 | + "raw": "qs@6.7.0", | ||
18 | + "name": "qs", | ||
19 | + "escapedName": "qs", | ||
20 | + "rawSpec": "6.7.0", | ||
21 | + "saveSpec": null, | ||
22 | + "fetchSpec": "6.7.0" | ||
23 | + }, | ||
24 | + "_requiredBy": [ | ||
25 | + "/body-parser" | ||
26 | + ], | ||
27 | + "_resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", | ||
28 | + "_spec": "6.7.0", | ||
29 | + "_where": "/Users/star/Desktop/YTMT", | ||
30 | + "bugs": { | ||
31 | + "url": "https://github.com/ljharb/qs/issues" | ||
32 | + }, | ||
33 | + "contributors": [ | ||
34 | + { | ||
35 | + "name": "Jordan Harband", | ||
36 | + "email": "ljharb@gmail.com", | ||
37 | + "url": "http://ljharb.codes" | ||
38 | + } | ||
39 | + ], | ||
40 | + "dependencies": {}, | ||
41 | + "description": "A querystring parser that supports nesting and arrays, with a depth limit", | ||
42 | + "devDependencies": { | ||
43 | + "@ljharb/eslint-config": "^13.1.1", | ||
44 | + "browserify": "^16.2.3", | ||
45 | + "covert": "^1.1.1", | ||
46 | + "editorconfig-tools": "^0.1.1", | ||
47 | + "eslint": "^5.15.3", | ||
48 | + "evalmd": "^0.0.17", | ||
49 | + "for-each": "^0.3.3", | ||
50 | + "iconv-lite": "^0.4.24", | ||
51 | + "mkdirp": "^0.5.1", | ||
52 | + "object-inspect": "^1.6.0", | ||
53 | + "qs-iconv": "^1.0.4", | ||
54 | + "safe-publish-latest": "^1.1.2", | ||
55 | + "safer-buffer": "^2.1.2", | ||
56 | + "tape": "^4.10.1" | ||
57 | + }, | ||
58 | + "engines": { | ||
59 | + "node": ">=0.6" | ||
60 | + }, | ||
61 | + "homepage": "https://github.com/ljharb/qs", | ||
62 | + "keywords": [ | ||
63 | + "querystring", | ||
64 | + "qs", | ||
65 | + "query", | ||
66 | + "url", | ||
67 | + "parse", | ||
68 | + "stringify" | ||
69 | + ], | ||
70 | + "license": "BSD-3-Clause", | ||
71 | + "main": "lib/index.js", | ||
72 | + "name": "qs", | ||
73 | + "repository": { | ||
74 | + "type": "git", | ||
75 | + "url": "git+https://github.com/ljharb/qs.git" | ||
76 | + }, | ||
77 | + "scripts": { | ||
78 | + "coverage": "covert test", | ||
79 | + "dist": "mkdirp dist && browserify --standalone Qs lib/index.js > dist/qs.js", | ||
80 | + "lint": "eslint lib/*.js test/*.js", | ||
81 | + "postlint": "editorconfig-tools check * lib/* test/*", | ||
82 | + "prepublish": "safe-publish-latest && npm run dist", | ||
83 | + "pretest": "npm run --silent readme && npm run --silent lint", | ||
84 | + "readme": "evalmd README.md", | ||
85 | + "test": "npm run --silent coverage", | ||
86 | + "tests-only": "node test" | ||
87 | + }, | ||
88 | + "version": "6.7.0" | ||
89 | +} |
1 | +{ | ||
2 | + "rules": { | ||
3 | + "array-bracket-newline": 0, | ||
4 | + "array-element-newline": 0, | ||
5 | + "consistent-return": 2, | ||
6 | + "function-paren-newline": 0, | ||
7 | + "max-lines": 0, | ||
8 | + "max-lines-per-function": 0, | ||
9 | + "max-nested-callbacks": [2, 3], | ||
10 | + "max-statements": 0, | ||
11 | + "no-buffer-constructor": 0, | ||
12 | + "no-extend-native": 0, | ||
13 | + "no-magic-numbers": 0, | ||
14 | + "object-curly-newline": 0, | ||
15 | + "sort-keys": 0 | ||
16 | + } | ||
17 | +} |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 | +'use strict'; | ||
2 | + | ||
3 | +var test = require('tape'); | ||
4 | +var inspect = require('object-inspect'); | ||
5 | +var SaferBuffer = require('safer-buffer').Buffer; | ||
6 | +var forEach = require('for-each'); | ||
7 | +var utils = require('../lib/utils'); | ||
8 | + | ||
9 | +test('merge()', function (t) { | ||
10 | + t.deepEqual(utils.merge(null, true), [null, true], 'merges true into null'); | ||
11 | + | ||
12 | + t.deepEqual(utils.merge(null, [42]), [null, 42], 'merges null into an array'); | ||
13 | + | ||
14 | + t.deepEqual(utils.merge({ a: 'b' }, { a: 'c' }), { a: ['b', 'c'] }, 'merges two objects with the same key'); | ||
15 | + | ||
16 | + var oneMerged = utils.merge({ foo: 'bar' }, { foo: { first: '123' } }); | ||
17 | + t.deepEqual(oneMerged, { foo: ['bar', { first: '123' }] }, 'merges a standalone and an object into an array'); | ||
18 | + | ||
19 | + var twoMerged = utils.merge({ foo: ['bar', { first: '123' }] }, { foo: { second: '456' } }); | ||
20 | + t.deepEqual(twoMerged, { foo: { 0: 'bar', 1: { first: '123' }, second: '456' } }, 'merges a standalone and two objects into an array'); | ||
21 | + | ||
22 | + var sandwiched = utils.merge({ foo: ['bar', { first: '123', second: '456' }] }, { foo: 'baz' }); | ||
23 | + t.deepEqual(sandwiched, { foo: ['bar', { first: '123', second: '456' }, 'baz'] }, 'merges an object sandwiched by two standalones into an array'); | ||
24 | + | ||
25 | + var nestedArrays = utils.merge({ foo: ['baz'] }, { foo: ['bar', 'xyzzy'] }); | ||
26 | + t.deepEqual(nestedArrays, { foo: ['baz', 'bar', 'xyzzy'] }); | ||
27 | + | ||
28 | + var noOptionsNonObjectSource = utils.merge({ foo: 'baz' }, 'bar'); | ||
29 | + t.deepEqual(noOptionsNonObjectSource, { foo: 'baz', bar: true }); | ||
30 | + | ||
31 | + t.test( | ||
32 | + 'avoids invoking array setters unnecessarily', | ||
33 | + { skip: typeof Object.defineProperty !== 'function' }, | ||
34 | + function (st) { | ||
35 | + var setCount = 0; | ||
36 | + var getCount = 0; | ||
37 | + var observed = []; | ||
38 | + Object.defineProperty(observed, 0, { | ||
39 | + get: function () { | ||
40 | + getCount += 1; | ||
41 | + return { bar: 'baz' }; | ||
42 | + }, | ||
43 | + set: function () { setCount += 1; } | ||
44 | + }); | ||
45 | + utils.merge(observed, [null]); | ||
46 | + st.equal(setCount, 0); | ||
47 | + st.equal(getCount, 1); | ||
48 | + observed[0] = observed[0]; // eslint-disable-line no-self-assign | ||
49 | + st.equal(setCount, 1); | ||
50 | + st.equal(getCount, 2); | ||
51 | + st.end(); | ||
52 | + } | ||
53 | + ); | ||
54 | + | ||
55 | + t.end(); | ||
56 | +}); | ||
57 | + | ||
58 | +test('assign()', function (t) { | ||
59 | + var target = { a: 1, b: 2 }; | ||
60 | + var source = { b: 3, c: 4 }; | ||
61 | + var result = utils.assign(target, source); | ||
62 | + | ||
63 | + t.equal(result, target, 'returns the target'); | ||
64 | + t.deepEqual(target, { a: 1, b: 3, c: 4 }, 'target and source are merged'); | ||
65 | + t.deepEqual(source, { b: 3, c: 4 }, 'source is untouched'); | ||
66 | + | ||
67 | + t.end(); | ||
68 | +}); | ||
69 | + | ||
70 | +test('combine()', function (t) { | ||
71 | + t.test('both arrays', function (st) { | ||
72 | + var a = [1]; | ||
73 | + var b = [2]; | ||
74 | + var combined = utils.combine(a, b); | ||
75 | + | ||
76 | + st.deepEqual(a, [1], 'a is not mutated'); | ||
77 | + st.deepEqual(b, [2], 'b is not mutated'); | ||
78 | + st.notEqual(a, combined, 'a !== combined'); | ||
79 | + st.notEqual(b, combined, 'b !== combined'); | ||
80 | + st.deepEqual(combined, [1, 2], 'combined is a + b'); | ||
81 | + | ||
82 | + st.end(); | ||
83 | + }); | ||
84 | + | ||
85 | + t.test('one array, one non-array', function (st) { | ||
86 | + var aN = 1; | ||
87 | + var a = [aN]; | ||
88 | + var bN = 2; | ||
89 | + var b = [bN]; | ||
90 | + | ||
91 | + var combinedAnB = utils.combine(aN, b); | ||
92 | + st.deepEqual(b, [bN], 'b is not mutated'); | ||
93 | + st.notEqual(aN, combinedAnB, 'aN + b !== aN'); | ||
94 | + st.notEqual(a, combinedAnB, 'aN + b !== a'); | ||
95 | + st.notEqual(bN, combinedAnB, 'aN + b !== bN'); | ||
96 | + st.notEqual(b, combinedAnB, 'aN + b !== b'); | ||
97 | + st.deepEqual([1, 2], combinedAnB, 'first argument is array-wrapped when not an array'); | ||
98 | + | ||
99 | + var combinedABn = utils.combine(a, bN); | ||
100 | + st.deepEqual(a, [aN], 'a is not mutated'); | ||
101 | + st.notEqual(aN, combinedABn, 'a + bN !== aN'); | ||
102 | + st.notEqual(a, combinedABn, 'a + bN !== a'); | ||
103 | + st.notEqual(bN, combinedABn, 'a + bN !== bN'); | ||
104 | + st.notEqual(b, combinedABn, 'a + bN !== b'); | ||
105 | + st.deepEqual([1, 2], combinedABn, 'second argument is array-wrapped when not an array'); | ||
106 | + | ||
107 | + st.end(); | ||
108 | + }); | ||
109 | + | ||
110 | + t.test('neither is an array', function (st) { | ||
111 | + var combined = utils.combine(1, 2); | ||
112 | + st.notEqual(1, combined, '1 + 2 !== 1'); | ||
113 | + st.notEqual(2, combined, '1 + 2 !== 2'); | ||
114 | + st.deepEqual([1, 2], combined, 'both arguments are array-wrapped when not an array'); | ||
115 | + | ||
116 | + st.end(); | ||
117 | + }); | ||
118 | + | ||
119 | + t.end(); | ||
120 | +}); | ||
121 | + | ||
122 | +test('isBuffer()', function (t) { | ||
123 | + forEach([null, undefined, true, false, '', 'abc', 42, 0, NaN, {}, [], function () {}, /a/g], function (x) { | ||
124 | + t.equal(utils.isBuffer(x), false, inspect(x) + ' is not a buffer'); | ||
125 | + }); | ||
126 | + | ||
127 | + var fakeBuffer = { constructor: Buffer }; | ||
128 | + t.equal(utils.isBuffer(fakeBuffer), false, 'fake buffer is not a buffer'); | ||
129 | + | ||
130 | + var saferBuffer = SaferBuffer.from('abc'); | ||
131 | + t.equal(utils.isBuffer(saferBuffer), true, 'SaferBuffer instance is a buffer'); | ||
132 | + | ||
133 | + var buffer = Buffer.from ? Buffer.from('abc') : new Buffer('abc'); | ||
134 | + t.equal(utils.isBuffer(buffer), true, 'real Buffer instance is a buffer'); | ||
135 | + t.end(); | ||
136 | +}); |
1 | +Copyright (c) 2015, Wes Todd | ||
2 | + | ||
3 | +Permission to use, copy, modify, and/or distribute this software for any | ||
4 | +purpose with or without fee is hereby granted, provided that the above | ||
5 | +copyright notice and this permission notice appear in all copies. | ||
6 | + | ||
7 | +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
8 | +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
9 | +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
10 | +SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
11 | +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION | ||
12 | +OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | ||
13 | +CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
1 | +# Polyfill for `Object.setPrototypeOf` | ||
2 | + | ||
3 | +[![NPM Version](https://img.shields.io/npm/v/setprototypeof.svg)](https://npmjs.org/package/setprototypeof) | ||
4 | +[![NPM Downloads](https://img.shields.io/npm/dm/setprototypeof.svg)](https://npmjs.org/package/setprototypeof) | ||
5 | +[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/standard/standard) | ||
6 | + | ||
7 | +A simple cross platform implementation to set the prototype of an instianted object. Supports all modern browsers and at least back to IE8. | ||
8 | + | ||
9 | +## Usage: | ||
10 | + | ||
11 | +``` | ||
12 | +$ npm install --save setprototypeof | ||
13 | +``` | ||
14 | + | ||
15 | +```javascript | ||
16 | +var setPrototypeOf = require('setprototypeof') | ||
17 | + | ||
18 | +var obj = {} | ||
19 | +setPrototypeOf(obj, { | ||
20 | + foo: function () { | ||
21 | + return 'bar' | ||
22 | + } | ||
23 | +}) | ||
24 | +obj.foo() // bar | ||
25 | +``` | ||
26 | + | ||
27 | +TypeScript is also supported: | ||
28 | + | ||
29 | +```typescript | ||
30 | +import setPrototypeOf = require('setprototypeof') | ||
31 | +``` |
1 | +'use strict' | ||
2 | +/* eslint no-proto: 0 */ | ||
3 | +module.exports = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array ? setProtoOf : mixinProperties) | ||
4 | + | ||
5 | +function setProtoOf (obj, proto) { | ||
6 | + obj.__proto__ = proto | ||
7 | + return obj | ||
8 | +} | ||
9 | + | ||
10 | +function mixinProperties (obj, proto) { | ||
11 | + for (var prop in proto) { | ||
12 | + if (!obj.hasOwnProperty(prop)) { | ||
13 | + obj[prop] = proto[prop] | ||
14 | + } | ||
15 | + } | ||
16 | + return obj | ||
17 | +} |
1 | +{ | ||
2 | + "_args": [ | ||
3 | + [ | ||
4 | + "setprototypeof@1.1.1", | ||
5 | + "/Users/star/Desktop/YTMT" | ||
6 | + ] | ||
7 | + ], | ||
8 | + "_from": "setprototypeof@1.1.1", | ||
9 | + "_id": "setprototypeof@1.1.1", | ||
10 | + "_inBundle": false, | ||
11 | + "_integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==", | ||
12 | + "_location": "/body-parser/setprototypeof", | ||
13 | + "_phantomChildren": {}, | ||
14 | + "_requested": { | ||
15 | + "type": "version", | ||
16 | + "registry": true, | ||
17 | + "raw": "setprototypeof@1.1.1", | ||
18 | + "name": "setprototypeof", | ||
19 | + "escapedName": "setprototypeof", | ||
20 | + "rawSpec": "1.1.1", | ||
21 | + "saveSpec": null, | ||
22 | + "fetchSpec": "1.1.1" | ||
23 | + }, | ||
24 | + "_requiredBy": [ | ||
25 | + "/body-parser/http-errors" | ||
26 | + ], | ||
27 | + "_resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", | ||
28 | + "_spec": "1.1.1", | ||
29 | + "_where": "/Users/star/Desktop/YTMT", | ||
30 | + "author": { | ||
31 | + "name": "Wes Todd" | ||
32 | + }, | ||
33 | + "bugs": { | ||
34 | + "url": "https://github.com/wesleytodd/setprototypeof/issues" | ||
35 | + }, | ||
36 | + "description": "A small polyfill for Object.setprototypeof", | ||
37 | + "devDependencies": { | ||
38 | + "mocha": "^5.2.0", | ||
39 | + "standard": "^12.0.1" | ||
40 | + }, | ||
41 | + "homepage": "https://github.com/wesleytodd/setprototypeof", | ||
42 | + "keywords": [ | ||
43 | + "polyfill", | ||
44 | + "object", | ||
45 | + "setprototypeof" | ||
46 | + ], | ||
47 | + "license": "ISC", | ||
48 | + "main": "index.js", | ||
49 | + "name": "setprototypeof", | ||
50 | + "repository": { | ||
51 | + "type": "git", | ||
52 | + "url": "git+https://github.com/wesleytodd/setprototypeof.git" | ||
53 | + }, | ||
54 | + "scripts": { | ||
55 | + "node010": "NODE_VER=0.10 MOCHA_VER=3 npm run testversion", | ||
56 | + "node11": "NODE_VER=11 npm run testversion", | ||
57 | + "node4": "NODE_VER=4 npm run testversion", | ||
58 | + "node6": "NODE_VER=6 npm run testversion", | ||
59 | + "node9": "NODE_VER=9 npm run testversion", | ||
60 | + "test": "standard && mocha", | ||
61 | + "testallversions": "npm run node010 && npm run node4 && npm run node6 && npm run node9 && npm run node11", | ||
62 | + "testversion": "docker run -it --rm -v $(PWD):/usr/src/app -w /usr/src/app node:${NODE_VER} npm install mocha@${MOCHA_VER:-latest} && npm t" | ||
63 | + }, | ||
64 | + "typings": "index.d.ts", | ||
65 | + "version": "1.1.1" | ||
66 | +} |
1 | +'use strict' | ||
2 | +/* eslint-env mocha */ | ||
3 | +/* eslint no-proto: 0 */ | ||
4 | +var assert = require('assert') | ||
5 | +var setPrototypeOf = require('..') | ||
6 | + | ||
7 | +describe('setProtoOf(obj, proto)', function () { | ||
8 | + it('should merge objects', function () { | ||
9 | + var obj = { a: 1, b: 2 } | ||
10 | + var proto = { b: 3, c: 4 } | ||
11 | + var mergeObj = setPrototypeOf(obj, proto) | ||
12 | + | ||
13 | + if (Object.getPrototypeOf) { | ||
14 | + assert.strictEqual(Object.getPrototypeOf(obj), proto) | ||
15 | + } else if ({ __proto__: [] } instanceof Array) { | ||
16 | + assert.strictEqual(obj.__proto__, proto) | ||
17 | + } else { | ||
18 | + assert.strictEqual(obj.a, 1) | ||
19 | + assert.strictEqual(obj.b, 2) | ||
20 | + assert.strictEqual(obj.c, 4) | ||
21 | + } | ||
22 | + assert.strictEqual(mergeObj, obj) | ||
23 | + }) | ||
24 | +}) |
1 | +1.6.18 / 2019-04-26 | ||
2 | +=================== | ||
3 | + | ||
4 | + * Fix regression passing request object to `typeis.is` | ||
5 | + | ||
6 | +1.6.17 / 2019-04-25 | ||
7 | +=================== | ||
8 | + | ||
9 | + * deps: mime-types@~2.1.24 | ||
10 | + - Add Apple file extensions from IANA | ||
11 | + - Add extension `.csl` to `application/vnd.citationstyles.style+xml` | ||
12 | + - Add extension `.es` to `application/ecmascript` | ||
13 | + - Add extension `.nq` to `application/n-quads` | ||
14 | + - Add extension `.nt` to `application/n-triples` | ||
15 | + - Add extension `.owl` to `application/rdf+xml` | ||
16 | + - Add extensions `.siv` and `.sieve` to `application/sieve` | ||
17 | + - Add extensions from IANA for `image/*` types | ||
18 | + - Add extensions from IANA for `model/*` types | ||
19 | + - Add extensions to HEIC image types | ||
20 | + - Add new mime types | ||
21 | + - Add `text/mdx` with extension `.mdx` | ||
22 | + * perf: prevent internal `throw` on invalid type | ||
23 | + | ||
24 | +1.6.16 / 2018-02-16 | ||
25 | +=================== | ||
26 | + | ||
27 | + * deps: mime-types@~2.1.18 | ||
28 | + - Add `application/raml+yaml` with extension `.raml` | ||
29 | + - Add `application/wasm` with extension `.wasm` | ||
30 | + - Add `text/shex` with extension `.shex` | ||
31 | + - Add extensions for JPEG-2000 images | ||
32 | + - Add extensions from IANA for `message/*` types | ||
33 | + - Add extension `.mjs` to `application/javascript` | ||
34 | + - Add extension `.wadl` to `application/vnd.sun.wadl+xml` | ||
35 | + - Add extension `.gz` to `application/gzip` | ||
36 | + - Add glTF types and extensions | ||
37 | + - Add new mime types | ||
38 | + - Update extensions `.md` and `.markdown` to be `text/markdown` | ||
39 | + - Update font MIME types | ||
40 | + - Update `text/hjson` to registered `application/hjson` | ||
41 | + | ||
42 | +1.6.15 / 2017-03-31 | ||
43 | +=================== | ||
44 | + | ||
45 | + * deps: mime-types@~2.1.15 | ||
46 | + - Add new mime types | ||
47 | + | ||
48 | +1.6.14 / 2016-11-18 | ||
49 | +=================== | ||
50 | + | ||
51 | + * deps: mime-types@~2.1.13 | ||
52 | + - Add new mime types | ||
53 | + | ||
54 | +1.6.13 / 2016-05-18 | ||
55 | +=================== | ||
56 | + | ||
57 | + * deps: mime-types@~2.1.11 | ||
58 | + - Add new mime types | ||
59 | + | ||
60 | +1.6.12 / 2016-02-28 | ||
61 | +=================== | ||
62 | + | ||
63 | + * deps: mime-types@~2.1.10 | ||
64 | + - Add new mime types | ||
65 | + - Fix extension of `application/dash+xml` | ||
66 | + - Update primary extension for `audio/mp4` | ||
67 | + | ||
68 | +1.6.11 / 2016-01-29 | ||
69 | +=================== | ||
70 | + | ||
71 | + * deps: mime-types@~2.1.9 | ||
72 | + - Add new mime types | ||
73 | + | ||
74 | +1.6.10 / 2015-12-01 | ||
75 | +=================== | ||
76 | + | ||
77 | + * deps: mime-types@~2.1.8 | ||
78 | + - Add new mime types | ||
79 | + | ||
80 | +1.6.9 / 2015-09-27 | ||
81 | +================== | ||
82 | + | ||
83 | + * deps: mime-types@~2.1.7 | ||
84 | + - Add new mime types | ||
85 | + | ||
86 | +1.6.8 / 2015-09-04 | ||
87 | +================== | ||
88 | + | ||
89 | + * deps: mime-types@~2.1.6 | ||
90 | + - Add new mime types | ||
91 | + | ||
92 | +1.6.7 / 2015-08-20 | ||
93 | +================== | ||
94 | + | ||
95 | + * Fix type error when given invalid type to match against | ||
96 | + * deps: mime-types@~2.1.5 | ||
97 | + - Add new mime types | ||
98 | + | ||
99 | +1.6.6 / 2015-07-31 | ||
100 | +================== | ||
101 | + | ||
102 | + * deps: mime-types@~2.1.4 | ||
103 | + - Add new mime types | ||
104 | + | ||
105 | +1.6.5 / 2015-07-16 | ||
106 | +================== | ||
107 | + | ||
108 | + * deps: mime-types@~2.1.3 | ||
109 | + - Add new mime types | ||
110 | + | ||
111 | +1.6.4 / 2015-07-01 | ||
112 | +================== | ||
113 | + | ||
114 | + * deps: mime-types@~2.1.2 | ||
115 | + - Add new mime types | ||
116 | + * perf: enable strict mode | ||
117 | + * perf: remove argument reassignment | ||
118 | + | ||
119 | +1.6.3 / 2015-06-08 | ||
120 | +================== | ||
121 | + | ||
122 | + * deps: mime-types@~2.1.1 | ||
123 | + - Add new mime types | ||
124 | + * perf: reduce try block size | ||
125 | + * perf: remove bitwise operations | ||
126 | + | ||
127 | +1.6.2 / 2015-05-10 | ||
128 | +================== | ||
129 | + | ||
130 | + * deps: mime-types@~2.0.11 | ||
131 | + - Add new mime types | ||
132 | + | ||
133 | +1.6.1 / 2015-03-13 | ||
134 | +================== | ||
135 | + | ||
136 | + * deps: mime-types@~2.0.10 | ||
137 | + - Add new mime types | ||
138 | + | ||
139 | +1.6.0 / 2015-02-12 | ||
140 | +================== | ||
141 | + | ||
142 | + * fix false-positives in `hasBody` `Transfer-Encoding` check | ||
143 | + * support wildcard for both type and subtype (`*/*`) | ||
144 | + | ||
145 | +1.5.7 / 2015-02-09 | ||
146 | +================== | ||
147 | + | ||
148 | + * fix argument reassignment | ||
149 | + * deps: mime-types@~2.0.9 | ||
150 | + - Add new mime types | ||
151 | + | ||
152 | +1.5.6 / 2015-01-29 | ||
153 | +================== | ||
154 | + | ||
155 | + * deps: mime-types@~2.0.8 | ||
156 | + - Add new mime types | ||
157 | + | ||
158 | +1.5.5 / 2014-12-30 | ||
159 | +================== | ||
160 | + | ||
161 | + * deps: mime-types@~2.0.7 | ||
162 | + - Add new mime types | ||
163 | + - Fix missing extensions | ||
164 | + - Fix various invalid MIME type entries | ||
165 | + - Remove example template MIME types | ||
166 | + - deps: mime-db@~1.5.0 | ||
167 | + | ||
168 | +1.5.4 / 2014-12-10 | ||
169 | +================== | ||
170 | + | ||
171 | + * deps: mime-types@~2.0.4 | ||
172 | + - Add new mime types | ||
173 | + - deps: mime-db@~1.3.0 | ||
174 | + | ||
175 | +1.5.3 / 2014-11-09 | ||
176 | +================== | ||
177 | + | ||
178 | + * deps: mime-types@~2.0.3 | ||
179 | + - Add new mime types | ||
180 | + - deps: mime-db@~1.2.0 | ||
181 | + | ||
182 | +1.5.2 / 2014-09-28 | ||
183 | +================== | ||
184 | + | ||
185 | + * deps: mime-types@~2.0.2 | ||
186 | + - Add new mime types | ||
187 | + - deps: mime-db@~1.1.0 | ||
188 | + | ||
189 | +1.5.1 / 2014-09-07 | ||
190 | +================== | ||
191 | + | ||
192 | + * Support Node.js 0.6 | ||
193 | + * deps: media-typer@0.3.0 | ||
194 | + * deps: mime-types@~2.0.1 | ||
195 | + - Support Node.js 0.6 | ||
196 | + | ||
197 | +1.5.0 / 2014-09-05 | ||
198 | +================== | ||
199 | + | ||
200 | + * fix `hasbody` to be true for `content-length: 0` | ||
201 | + | ||
202 | +1.4.0 / 2014-09-02 | ||
203 | +================== | ||
204 | + | ||
205 | + * update mime-types | ||
206 | + | ||
207 | +1.3.2 / 2014-06-24 | ||
208 | +================== | ||
209 | + | ||
210 | + * use `~` range on mime-types | ||
211 | + | ||
212 | +1.3.1 / 2014-06-19 | ||
213 | +================== | ||
214 | + | ||
215 | + * fix global variable leak | ||
216 | + | ||
217 | +1.3.0 / 2014-06-19 | ||
218 | +================== | ||
219 | + | ||
220 | + * improve type parsing | ||
221 | + | ||
222 | + - invalid media type never matches | ||
223 | + - media type not case-sensitive | ||
224 | + - extra LWS does not affect results | ||
225 | + | ||
226 | +1.2.2 / 2014-06-19 | ||
227 | +================== | ||
228 | + | ||
229 | + * fix behavior on unknown type argument | ||
230 | + | ||
231 | +1.2.1 / 2014-06-03 | ||
232 | +================== | ||
233 | + | ||
234 | + * switch dependency from `mime` to `mime-types@1.0.0` | ||
235 | + | ||
236 | +1.2.0 / 2014-05-11 | ||
237 | +================== | ||
238 | + | ||
239 | + * support suffix matching: | ||
240 | + | ||
241 | + - `+json` matches `application/vnd+json` | ||
242 | + - `*/vnd+json` matches `application/vnd+json` | ||
243 | + - `application/*+json` matches `application/vnd+json` | ||
244 | + | ||
245 | +1.1.0 / 2014-04-12 | ||
246 | +================== | ||
247 | + | ||
248 | + * add non-array values support | ||
249 | + * expose internal utilities: | ||
250 | + | ||
251 | + - `.is()` | ||
252 | + - `.hasBody()` | ||
253 | + - `.normalize()` | ||
254 | + - `.match()` | ||
255 | + | ||
256 | +1.0.1 / 2014-03-30 | ||
257 | +================== | ||
258 | + | ||
259 | + * add `multipart` as a shorthand |
1 | +(The MIT License) | ||
2 | + | ||
3 | +Copyright (c) 2014 Jonathan Ong <me@jongleberry.com> | ||
4 | +Copyright (c) 2014-2015 Douglas Christopher Wilson <doug@somethingdoug.com> | ||
5 | + | ||
6 | +Permission is hereby granted, free of charge, to any person obtaining | ||
7 | +a copy of this software and associated documentation files (the | ||
8 | +'Software'), to deal in the Software without restriction, including | ||
9 | +without limitation the rights to use, copy, modify, merge, publish, | ||
10 | +distribute, sublicense, and/or sell copies of the Software, and to | ||
11 | +permit persons to whom the Software is furnished to do so, subject to | ||
12 | +the following conditions: | ||
13 | + | ||
14 | +The above copyright notice and this permission notice shall be | ||
15 | +included in all copies or substantial portions of the Software. | ||
16 | + | ||
17 | +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
18 | +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
19 | +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
20 | +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
21 | +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
22 | +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
23 | +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
1 | +# type-is | ||
2 | + | ||
3 | +[![NPM Version][npm-version-image]][npm-url] | ||
4 | +[![NPM Downloads][npm-downloads-image]][npm-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 | +Infer the content-type of a request. | ||
10 | + | ||
11 | +### Install | ||
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 type-is | ||
19 | +``` | ||
20 | + | ||
21 | +## API | ||
22 | + | ||
23 | +```js | ||
24 | +var http = require('http') | ||
25 | +var typeis = require('type-is') | ||
26 | + | ||
27 | +http.createServer(function (req, res) { | ||
28 | + var istext = typeis(req, ['text/*']) | ||
29 | + res.end('you ' + (istext ? 'sent' : 'did not send') + ' me text') | ||
30 | +}) | ||
31 | +``` | ||
32 | + | ||
33 | +### typeis(request, types) | ||
34 | + | ||
35 | +Checks if the `request` is one of the `types`. If the request has no body, | ||
36 | +even if there is a `Content-Type` header, then `null` is returned. If the | ||
37 | +`Content-Type` header is invalid or does not matches any of the `types`, then | ||
38 | +`false` is returned. Otherwise, a string of the type that matched is returned. | ||
39 | + | ||
40 | +The `request` argument is expected to be a Node.js HTTP request. The `types` | ||
41 | +argument is an array of type strings. | ||
42 | + | ||
43 | +Each type in the `types` array can be one of the following: | ||
44 | + | ||
45 | +- A file extension name such as `json`. This name will be returned if matched. | ||
46 | +- A mime type such as `application/json`. | ||
47 | +- A mime type with a wildcard such as `*/*` or `*/json` or `application/*`. | ||
48 | + The full mime type will be returned if matched. | ||
49 | +- A suffix such as `+json`. This can be combined with a wildcard such as | ||
50 | + `*/vnd+json` or `application/*+json`. The full mime type will be returned | ||
51 | + if matched. | ||
52 | + | ||
53 | +Some examples to illustrate the inputs and returned value: | ||
54 | + | ||
55 | +<!-- eslint-disable no-undef --> | ||
56 | + | ||
57 | +```js | ||
58 | +// req.headers.content-type = 'application/json' | ||
59 | + | ||
60 | +typeis(req, ['json']) // => 'json' | ||
61 | +typeis(req, ['html', 'json']) // => 'json' | ||
62 | +typeis(req, ['application/*']) // => 'application/json' | ||
63 | +typeis(req, ['application/json']) // => 'application/json' | ||
64 | + | ||
65 | +typeis(req, ['html']) // => false | ||
66 | +``` | ||
67 | + | ||
68 | +### typeis.hasBody(request) | ||
69 | + | ||
70 | +Returns a Boolean if the given `request` has a body, regardless of the | ||
71 | +`Content-Type` header. | ||
72 | + | ||
73 | +Having a body has no relation to how large the body is (it may be 0 bytes). | ||
74 | +This is similar to how file existence works. If a body does exist, then this | ||
75 | +indicates that there is data to read from the Node.js request stream. | ||
76 | + | ||
77 | +<!-- eslint-disable no-undef --> | ||
78 | + | ||
79 | +```js | ||
80 | +if (typeis.hasBody(req)) { | ||
81 | + // read the body, since there is one | ||
82 | + | ||
83 | + req.on('data', function (chunk) { | ||
84 | + // ... | ||
85 | + }) | ||
86 | +} | ||
87 | +``` | ||
88 | + | ||
89 | +### typeis.is(mediaType, types) | ||
90 | + | ||
91 | +Checks if the `mediaType` is one of the `types`. If the `mediaType` is invalid | ||
92 | +or does not matches any of the `types`, then `false` is returned. Otherwise, a | ||
93 | +string of the type that matched is returned. | ||
94 | + | ||
95 | +The `mediaType` argument is expected to be a | ||
96 | +[media type](https://tools.ietf.org/html/rfc6838) string. The `types` argument | ||
97 | +is an array of type strings. | ||
98 | + | ||
99 | +Each type in the `types` array can be one of the following: | ||
100 | + | ||
101 | +- A file extension name such as `json`. This name will be returned if matched. | ||
102 | +- A mime type such as `application/json`. | ||
103 | +- A mime type with a wildcard such as `*/*` or `*/json` or `application/*`. | ||
104 | + The full mime type will be returned if matched. | ||
105 | +- A suffix such as `+json`. This can be combined with a wildcard such as | ||
106 | + `*/vnd+json` or `application/*+json`. The full mime type will be returned | ||
107 | + if matched. | ||
108 | + | ||
109 | +Some examples to illustrate the inputs and returned value: | ||
110 | + | ||
111 | +<!-- eslint-disable no-undef --> | ||
112 | + | ||
113 | +```js | ||
114 | +var mediaType = 'application/json' | ||
115 | + | ||
116 | +typeis.is(mediaType, ['json']) // => 'json' | ||
117 | +typeis.is(mediaType, ['html', 'json']) // => 'json' | ||
118 | +typeis.is(mediaType, ['application/*']) // => 'application/json' | ||
119 | +typeis.is(mediaType, ['application/json']) // => 'application/json' | ||
120 | + | ||
121 | +typeis.is(mediaType, ['html']) // => false | ||
122 | +``` | ||
123 | + | ||
124 | +## Examples | ||
125 | + | ||
126 | +### Example body parser | ||
127 | + | ||
128 | +```js | ||
129 | +var express = require('express') | ||
130 | +var typeis = require('type-is') | ||
131 | + | ||
132 | +var app = express() | ||
133 | + | ||
134 | +app.use(function bodyParser (req, res, next) { | ||
135 | + if (!typeis.hasBody(req)) { | ||
136 | + return next() | ||
137 | + } | ||
138 | + | ||
139 | + switch (typeis(req, ['urlencoded', 'json', 'multipart'])) { | ||
140 | + case 'urlencoded': | ||
141 | + // parse urlencoded body | ||
142 | + throw new Error('implement urlencoded body parsing') | ||
143 | + case 'json': | ||
144 | + // parse json body | ||
145 | + throw new Error('implement json body parsing') | ||
146 | + case 'multipart': | ||
147 | + // parse multipart body | ||
148 | + throw new Error('implement multipart body parsing') | ||
149 | + default: | ||
150 | + // 415 error code | ||
151 | + res.statusCode = 415 | ||
152 | + res.end() | ||
153 | + break | ||
154 | + } | ||
155 | +}) | ||
156 | +``` | ||
157 | + | ||
158 | +## License | ||
159 | + | ||
160 | +[MIT](LICENSE) | ||
161 | + | ||
162 | +[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/type-is/master | ||
163 | +[coveralls-url]: https://coveralls.io/r/jshttp/type-is?branch=master | ||
164 | +[node-version-image]: https://badgen.net/npm/node/type-is | ||
165 | +[node-version-url]: https://nodejs.org/en/download | ||
166 | +[npm-downloads-image]: https://badgen.net/npm/dm/type-is | ||
167 | +[npm-url]: https://npmjs.org/package/type-is | ||
168 | +[npm-version-image]: https://badgen.net/npm/v/type-is | ||
169 | +[travis-image]: https://badgen.net/travis/jshttp/type-is/master | ||
170 | +[travis-url]: https://travis-ci.org/jshttp/type-is |
1 | +/*! | ||
2 | + * type-is | ||
3 | + * Copyright(c) 2014 Jonathan Ong | ||
4 | + * Copyright(c) 2014-2015 Douglas Christopher Wilson | ||
5 | + * MIT Licensed | ||
6 | + */ | ||
7 | + | ||
8 | +'use strict' | ||
9 | + | ||
10 | +/** | ||
11 | + * Module dependencies. | ||
12 | + * @private | ||
13 | + */ | ||
14 | + | ||
15 | +var typer = require('media-typer') | ||
16 | +var mime = require('mime-types') | ||
17 | + | ||
18 | +/** | ||
19 | + * Module exports. | ||
20 | + * @public | ||
21 | + */ | ||
22 | + | ||
23 | +module.exports = typeofrequest | ||
24 | +module.exports.is = typeis | ||
25 | +module.exports.hasBody = hasbody | ||
26 | +module.exports.normalize = normalize | ||
27 | +module.exports.match = mimeMatch | ||
28 | + | ||
29 | +/** | ||
30 | + * Compare a `value` content-type with `types`. | ||
31 | + * Each `type` can be an extension like `html`, | ||
32 | + * a special shortcut like `multipart` or `urlencoded`, | ||
33 | + * or a mime type. | ||
34 | + * | ||
35 | + * If no types match, `false` is returned. | ||
36 | + * Otherwise, the first `type` that matches is returned. | ||
37 | + * | ||
38 | + * @param {String} value | ||
39 | + * @param {Array} types | ||
40 | + * @public | ||
41 | + */ | ||
42 | + | ||
43 | +function typeis (value, types_) { | ||
44 | + var i | ||
45 | + var types = types_ | ||
46 | + | ||
47 | + // remove parameters and normalize | ||
48 | + var val = tryNormalizeType(value) | ||
49 | + | ||
50 | + // no type or invalid | ||
51 | + if (!val) { | ||
52 | + return false | ||
53 | + } | ||
54 | + | ||
55 | + // support flattened arguments | ||
56 | + if (types && !Array.isArray(types)) { | ||
57 | + types = new Array(arguments.length - 1) | ||
58 | + for (i = 0; i < types.length; i++) { | ||
59 | + types[i] = arguments[i + 1] | ||
60 | + } | ||
61 | + } | ||
62 | + | ||
63 | + // no types, return the content type | ||
64 | + if (!types || !types.length) { | ||
65 | + return val | ||
66 | + } | ||
67 | + | ||
68 | + var type | ||
69 | + for (i = 0; i < types.length; i++) { | ||
70 | + if (mimeMatch(normalize(type = types[i]), val)) { | ||
71 | + return type[0] === '+' || type.indexOf('*') !== -1 | ||
72 | + ? val | ||
73 | + : type | ||
74 | + } | ||
75 | + } | ||
76 | + | ||
77 | + // no matches | ||
78 | + return false | ||
79 | +} | ||
80 | + | ||
81 | +/** | ||
82 | + * Check if a request has a request body. | ||
83 | + * A request with a body __must__ either have `transfer-encoding` | ||
84 | + * or `content-length` headers set. | ||
85 | + * http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3 | ||
86 | + * | ||
87 | + * @param {Object} request | ||
88 | + * @return {Boolean} | ||
89 | + * @public | ||
90 | + */ | ||
91 | + | ||
92 | +function hasbody (req) { | ||
93 | + return req.headers['transfer-encoding'] !== undefined || | ||
94 | + !isNaN(req.headers['content-length']) | ||
95 | +} | ||
96 | + | ||
97 | +/** | ||
98 | + * Check if the incoming request contains the "Content-Type" | ||
99 | + * header field, and it contains any of the give mime `type`s. | ||
100 | + * If there is no request body, `null` is returned. | ||
101 | + * If there is no content type, `false` is returned. | ||
102 | + * Otherwise, it returns the first `type` that matches. | ||
103 | + * | ||
104 | + * Examples: | ||
105 | + * | ||
106 | + * // With Content-Type: text/html; charset=utf-8 | ||
107 | + * this.is('html'); // => 'html' | ||
108 | + * this.is('text/html'); // => 'text/html' | ||
109 | + * this.is('text/*', 'application/json'); // => 'text/html' | ||
110 | + * | ||
111 | + * // When Content-Type is application/json | ||
112 | + * this.is('json', 'urlencoded'); // => 'json' | ||
113 | + * this.is('application/json'); // => 'application/json' | ||
114 | + * this.is('html', 'application/*'); // => 'application/json' | ||
115 | + * | ||
116 | + * this.is('html'); // => false | ||
117 | + * | ||
118 | + * @param {String|Array} types... | ||
119 | + * @return {String|false|null} | ||
120 | + * @public | ||
121 | + */ | ||
122 | + | ||
123 | +function typeofrequest (req, types_) { | ||
124 | + var types = types_ | ||
125 | + | ||
126 | + // no body | ||
127 | + if (!hasbody(req)) { | ||
128 | + return null | ||
129 | + } | ||
130 | + | ||
131 | + // support flattened arguments | ||
132 | + if (arguments.length > 2) { | ||
133 | + types = new Array(arguments.length - 1) | ||
134 | + for (var i = 0; i < types.length; i++) { | ||
135 | + types[i] = arguments[i + 1] | ||
136 | + } | ||
137 | + } | ||
138 | + | ||
139 | + // request content type | ||
140 | + var value = req.headers['content-type'] | ||
141 | + | ||
142 | + return typeis(value, types) | ||
143 | +} | ||
144 | + | ||
145 | +/** | ||
146 | + * Normalize a mime type. | ||
147 | + * If it's a shorthand, expand it to a valid mime type. | ||
148 | + * | ||
149 | + * In general, you probably want: | ||
150 | + * | ||
151 | + * var type = is(req, ['urlencoded', 'json', 'multipart']); | ||
152 | + * | ||
153 | + * Then use the appropriate body parsers. | ||
154 | + * These three are the most common request body types | ||
155 | + * and are thus ensured to work. | ||
156 | + * | ||
157 | + * @param {String} type | ||
158 | + * @private | ||
159 | + */ | ||
160 | + | ||
161 | +function normalize (type) { | ||
162 | + if (typeof type !== 'string') { | ||
163 | + // invalid type | ||
164 | + return false | ||
165 | + } | ||
166 | + | ||
167 | + switch (type) { | ||
168 | + case 'urlencoded': | ||
169 | + return 'application/x-www-form-urlencoded' | ||
170 | + case 'multipart': | ||
171 | + return 'multipart/*' | ||
172 | + } | ||
173 | + | ||
174 | + if (type[0] === '+') { | ||
175 | + // "+json" -> "*/*+json" expando | ||
176 | + return '*/*' + type | ||
177 | + } | ||
178 | + | ||
179 | + return type.indexOf('/') === -1 | ||
180 | + ? mime.lookup(type) | ||
181 | + : type | ||
182 | +} | ||
183 | + | ||
184 | +/** | ||
185 | + * Check if `expected` mime type | ||
186 | + * matches `actual` mime type with | ||
187 | + * wildcard and +suffix support. | ||
188 | + * | ||
189 | + * @param {String} expected | ||
190 | + * @param {String} actual | ||
191 | + * @return {Boolean} | ||
192 | + * @private | ||
193 | + */ | ||
194 | + | ||
195 | +function mimeMatch (expected, actual) { | ||
196 | + // invalid type | ||
197 | + if (expected === false) { | ||
198 | + return false | ||
199 | + } | ||
200 | + | ||
201 | + // split types | ||
202 | + var actualParts = actual.split('/') | ||
203 | + var expectedParts = expected.split('/') | ||
204 | + | ||
205 | + // invalid format | ||
206 | + if (actualParts.length !== 2 || expectedParts.length !== 2) { | ||
207 | + return false | ||
208 | + } | ||
209 | + | ||
210 | + // validate type | ||
211 | + if (expectedParts[0] !== '*' && expectedParts[0] !== actualParts[0]) { | ||
212 | + return false | ||
213 | + } | ||
214 | + | ||
215 | + // validate suffix wildcard | ||
216 | + if (expectedParts[1].substr(0, 2) === '*+') { | ||
217 | + return expectedParts[1].length <= actualParts[1].length + 1 && | ||
218 | + expectedParts[1].substr(1) === actualParts[1].substr(1 - expectedParts[1].length) | ||
219 | + } | ||
220 | + | ||
221 | + // validate subtype | ||
222 | + if (expectedParts[1] !== '*' && expectedParts[1] !== actualParts[1]) { | ||
223 | + return false | ||
224 | + } | ||
225 | + | ||
226 | + return true | ||
227 | +} | ||
228 | + | ||
229 | +/** | ||
230 | + * Normalize a type and remove parameters. | ||
231 | + * | ||
232 | + * @param {string} value | ||
233 | + * @return {string} | ||
234 | + * @private | ||
235 | + */ | ||
236 | + | ||
237 | +function normalizeType (value) { | ||
238 | + // parse the type | ||
239 | + var type = typer.parse(value) | ||
240 | + | ||
241 | + // remove the parameters | ||
242 | + type.parameters = undefined | ||
243 | + | ||
244 | + // reformat it | ||
245 | + return typer.format(type) | ||
246 | +} | ||
247 | + | ||
248 | +/** | ||
249 | + * Try to normalize a type and remove parameters. | ||
250 | + * | ||
251 | + * @param {string} value | ||
252 | + * @return {string} | ||
253 | + * @private | ||
254 | + */ | ||
255 | + | ||
256 | +function tryNormalizeType (value) { | ||
257 | + if (!value) { | ||
258 | + return null | ||
259 | + } | ||
260 | + | ||
261 | + try { | ||
262 | + return normalizeType(value) | ||
263 | + } catch (err) { | ||
264 | + return null | ||
265 | + } | ||
266 | +} |
1 | +{ | ||
2 | + "_args": [ | ||
3 | + [ | ||
4 | + "type-is@1.6.18", | ||
5 | + "/Users/star/Desktop/YTMT" | ||
6 | + ] | ||
7 | + ], | ||
8 | + "_from": "type-is@1.6.18", | ||
9 | + "_id": "type-is@1.6.18", | ||
10 | + "_inBundle": false, | ||
11 | + "_integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", | ||
12 | + "_location": "/body-parser/type-is", | ||
13 | + "_phantomChildren": {}, | ||
14 | + "_requested": { | ||
15 | + "type": "version", | ||
16 | + "registry": true, | ||
17 | + "raw": "type-is@1.6.18", | ||
18 | + "name": "type-is", | ||
19 | + "escapedName": "type-is", | ||
20 | + "rawSpec": "1.6.18", | ||
21 | + "saveSpec": null, | ||
22 | + "fetchSpec": "1.6.18" | ||
23 | + }, | ||
24 | + "_requiredBy": [ | ||
25 | + "/body-parser" | ||
26 | + ], | ||
27 | + "_resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", | ||
28 | + "_spec": "1.6.18", | ||
29 | + "_where": "/Users/star/Desktop/YTMT", | ||
30 | + "bugs": { | ||
31 | + "url": "https://github.com/jshttp/type-is/issues" | ||
32 | + }, | ||
33 | + "contributors": [ | ||
34 | + { | ||
35 | + "name": "Douglas Christopher Wilson", | ||
36 | + "email": "doug@somethingdoug.com" | ||
37 | + }, | ||
38 | + { | ||
39 | + "name": "Jonathan Ong", | ||
40 | + "email": "me@jongleberry.com", | ||
41 | + "url": "http://jongleberry.com" | ||
42 | + } | ||
43 | + ], | ||
44 | + "dependencies": { | ||
45 | + "media-typer": "0.3.0", | ||
46 | + "mime-types": "~2.1.24" | ||
47 | + }, | ||
48 | + "description": "Infer the content-type of a request.", | ||
49 | + "devDependencies": { | ||
50 | + "eslint": "5.16.0", | ||
51 | + "eslint-config-standard": "12.0.0", | ||
52 | + "eslint-plugin-import": "2.17.2", | ||
53 | + "eslint-plugin-markdown": "1.0.0", | ||
54 | + "eslint-plugin-node": "8.0.1", | ||
55 | + "eslint-plugin-promise": "4.1.1", | ||
56 | + "eslint-plugin-standard": "4.0.0", | ||
57 | + "mocha": "6.1.4", | ||
58 | + "nyc": "14.0.0" | ||
59 | + }, | ||
60 | + "engines": { | ||
61 | + "node": ">= 0.6" | ||
62 | + }, | ||
63 | + "files": [ | ||
64 | + "LICENSE", | ||
65 | + "HISTORY.md", | ||
66 | + "index.js" | ||
67 | + ], | ||
68 | + "homepage": "https://github.com/jshttp/type-is#readme", | ||
69 | + "keywords": [ | ||
70 | + "content", | ||
71 | + "type", | ||
72 | + "checking" | ||
73 | + ], | ||
74 | + "license": "MIT", | ||
75 | + "name": "type-is", | ||
76 | + "repository": { | ||
77 | + "type": "git", | ||
78 | + "url": "git+https://github.com/jshttp/type-is.git" | ||
79 | + }, | ||
80 | + "scripts": { | ||
81 | + "lint": "eslint --plugin markdown --ext js,md .", | ||
82 | + "test": "mocha --reporter spec --check-leaks --bail test/", | ||
83 | + "test-cov": "nyc --reporter=html --reporter=text npm test", | ||
84 | + "test-travis": "nyc --reporter=text npm test" | ||
85 | + }, | ||
86 | + "version": "1.6.18" | ||
87 | +} |
1 | { | 1 | { |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | - "body-parser@1.18.3", | 4 | + "body-parser@1.19.0", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | - "_from": "body-parser@1.18.3", | 8 | + "_from": "body-parser@1.19.0", |
9 | - "_id": "body-parser@1.18.3", | 9 | + "_id": "body-parser@1.19.0", |
10 | "_inBundle": false, | 10 | "_inBundle": false, |
11 | - "_integrity": "sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ=", | 11 | + "_integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", |
12 | "_location": "/body-parser", | 12 | "_location": "/body-parser", |
13 | - "_phantomChildren": {}, | 13 | + "_phantomChildren": { |
14 | + "depd": "1.1.2", | ||
15 | + "inherits": "2.0.3", | ||
16 | + "media-typer": "0.3.0", | ||
17 | + "statuses": "1.5.0", | ||
18 | + "toidentifier": "1.0.0" | ||
19 | + }, | ||
14 | "_requested": { | 20 | "_requested": { |
15 | "type": "version", | 21 | "type": "version", |
16 | "registry": true, | 22 | "registry": true, |
17 | - "raw": "body-parser@1.18.3", | 23 | + "raw": "body-parser@1.19.0", |
18 | "name": "body-parser", | 24 | "name": "body-parser", |
19 | "escapedName": "body-parser", | 25 | "escapedName": "body-parser", |
20 | - "rawSpec": "1.18.3", | 26 | + "rawSpec": "1.19.0", |
21 | "saveSpec": null, | 27 | "saveSpec": null, |
22 | - "fetchSpec": "1.18.3" | 28 | + "fetchSpec": "1.19.0" |
23 | }, | 29 | }, |
24 | "_requiredBy": [ | 30 | "_requiredBy": [ |
25 | - "/", | 31 | + "/" |
26 | - "/express" | ||
27 | ], | 32 | ], |
28 | - "_resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz", | 33 | + "_resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", |
29 | - "_spec": "1.18.3", | 34 | + "_spec": "1.19.0", |
30 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 35 | + "_where": "/Users/star/Desktop/YTMT", |
31 | "bugs": { | 36 | "bugs": { |
32 | "url": "https://github.com/expressjs/body-parser/issues" | 37 | "url": "https://github.com/expressjs/body-parser/issues" |
33 | }, | 38 | }, |
... | @@ -43,31 +48,31 @@ | ... | @@ -43,31 +48,31 @@ |
43 | } | 48 | } |
44 | ], | 49 | ], |
45 | "dependencies": { | 50 | "dependencies": { |
46 | - "bytes": "3.0.0", | 51 | + "bytes": "3.1.0", |
47 | "content-type": "~1.0.4", | 52 | "content-type": "~1.0.4", |
48 | "debug": "2.6.9", | 53 | "debug": "2.6.9", |
49 | "depd": "~1.1.2", | 54 | "depd": "~1.1.2", |
50 | - "http-errors": "~1.6.3", | 55 | + "http-errors": "1.7.2", |
51 | - "iconv-lite": "0.4.23", | 56 | + "iconv-lite": "0.4.24", |
52 | "on-finished": "~2.3.0", | 57 | "on-finished": "~2.3.0", |
53 | - "qs": "6.5.2", | 58 | + "qs": "6.7.0", |
54 | - "raw-body": "2.3.3", | 59 | + "raw-body": "2.4.0", |
55 | - "type-is": "~1.6.16" | 60 | + "type-is": "~1.6.17" |
56 | }, | 61 | }, |
57 | "description": "Node.js body parsing middleware", | 62 | "description": "Node.js body parsing middleware", |
58 | "devDependencies": { | 63 | "devDependencies": { |
59 | - "eslint": "4.19.1", | 64 | + "eslint": "5.16.0", |
60 | - "eslint-config-standard": "11.0.0", | 65 | + "eslint-config-standard": "12.0.0", |
61 | - "eslint-plugin-import": "2.11.0", | 66 | + "eslint-plugin-import": "2.17.2", |
62 | - "eslint-plugin-markdown": "1.0.0-beta.6", | 67 | + "eslint-plugin-markdown": "1.0.0", |
63 | - "eslint-plugin-node": "6.0.1", | 68 | + "eslint-plugin-node": "8.0.1", |
64 | - "eslint-plugin-promise": "3.7.0", | 69 | + "eslint-plugin-promise": "4.1.1", |
65 | - "eslint-plugin-standard": "3.1.0", | 70 | + "eslint-plugin-standard": "4.0.0", |
66 | "istanbul": "0.4.5", | 71 | "istanbul": "0.4.5", |
67 | "methods": "1.1.2", | 72 | "methods": "1.1.2", |
68 | - "mocha": "2.5.3", | 73 | + "mocha": "6.1.4", |
69 | "safe-buffer": "5.1.2", | 74 | "safe-buffer": "5.1.2", |
70 | - "supertest": "1.1.0" | 75 | + "supertest": "4.0.2" |
71 | }, | 76 | }, |
72 | "engines": { | 77 | "engines": { |
73 | "node": ">= 0.8" | 78 | "node": ">= 0.8" |
... | @@ -91,5 +96,5 @@ | ... | @@ -91,5 +96,5 @@ |
91 | "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/", | 96 | "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/", |
92 | "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/" | 97 | "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/" |
93 | }, | 98 | }, |
94 | - "version": "1.18.3" | 99 | + "version": "1.19.0" |
95 | } | 100 | } | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "boolbase@1.0.0", | 4 | "boolbase@1.0.0", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "boolbase@1.0.0", | 8 | "_from": "boolbase@1.0.0", |
... | @@ -27,7 +27,7 @@ | ... | @@ -27,7 +27,7 @@ |
27 | ], | 27 | ], |
28 | "_resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", | 28 | "_resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", |
29 | "_spec": "1.0.0", | 29 | "_spec": "1.0.0", |
30 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 30 | + "_where": "/Users/star/Desktop/YTMT", |
31 | "author": { | 31 | "author": { |
32 | "name": "Felix Boehm", | 32 | "name": "Felix Boehm", |
33 | "email": "me@feedic.com" | 33 | "email": "me@feedic.com" | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "boom@2.10.1", | 4 | "boom@2.10.1", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "boom@2.10.1", | 8 | "_from": "boom@2.10.1", |
... | @@ -27,7 +27,7 @@ | ... | @@ -27,7 +27,7 @@ |
27 | ], | 27 | ], |
28 | "_resolved": "http://registry.npmjs.org/boom/-/boom-2.10.1.tgz", | 28 | "_resolved": "http://registry.npmjs.org/boom/-/boom-2.10.1.tgz", |
29 | "_spec": "2.10.1", | 29 | "_spec": "2.10.1", |
30 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 30 | + "_where": "/Users/star/Desktop/YTMT", |
31 | "bugs": { | 31 | "bugs": { |
32 | "url": "https://github.com/hapijs/boom/issues" | 32 | "url": "https://github.com/hapijs/boom/issues" |
33 | }, | 33 | }, | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "brace-expansion@1.1.11", | 4 | "brace-expansion@1.1.11", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "brace-expansion@1.1.11", | 8 | "_from": "brace-expansion@1.1.11", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", | 27 | "_resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", |
28 | "_spec": "1.1.11", | 28 | "_spec": "1.1.11", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "Julian Gruber", | 31 | "name": "Julian Gruber", |
32 | "email": "mail@juliangruber.com", | 32 | "email": "mail@juliangruber.com", | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "bson@1.1.3", | 4 | "bson@1.1.3", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "bson@1.1.3", | 8 | "_from": "bson@1.1.3", |
... | @@ -27,7 +27,7 @@ | ... | @@ -27,7 +27,7 @@ |
27 | ], | 27 | ], |
28 | "_resolved": "https://registry.npmjs.org/bson/-/bson-1.1.3.tgz", | 28 | "_resolved": "https://registry.npmjs.org/bson/-/bson-1.1.3.tgz", |
29 | "_spec": "1.1.3", | 29 | "_spec": "1.1.3", |
30 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 30 | + "_where": "/Users/star/Desktop/YTMT", |
31 | "author": { | 31 | "author": { |
32 | "name": "Christian Amor Kvalheim", | 32 | "name": "Christian Amor Kvalheim", |
33 | "email": "christkv@gmail.com" | 33 | "email": "christkv@gmail.com" | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "buffer-from@1.1.1", | 4 | "buffer-from@1.1.1", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "buffer-from@1.1.1", | 8 | "_from": "buffer-from@1.1.1", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", | 27 | "_resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", |
28 | "_spec": "1.1.1", | 28 | "_spec": "1.1.1", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "bugs": { | 30 | "bugs": { |
31 | "url": "https://github.com/LinusU/buffer-from/issues" | 31 | "url": "https://github.com/LinusU/buffer-from/issues" |
32 | }, | 32 | }, | ... | ... |
... | @@ -83,6 +83,7 @@ Supported units and abbreviations are as follows and are case-insensitive: | ... | @@ -83,6 +83,7 @@ Supported units and abbreviations are as follows and are case-insensitive: |
83 | * `mb` for megabytes | 83 | * `mb` for megabytes |
84 | * `gb` for gigabytes | 84 | * `gb` for gigabytes |
85 | * `tb` for terabytes | 85 | * `tb` for terabytes |
86 | + * `pb` for petabytes | ||
86 | 87 | ||
87 | The units are in powers of two, not ten. This means 1kb = 1024b according to this parser. | 88 | The units are in powers of two, not ten. This means 1kb = 1024b according to this parser. |
88 | 89 | ||
... | @@ -108,18 +109,18 @@ bytes('1024'); | ... | @@ -108,18 +109,18 @@ bytes('1024'); |
108 | // output: 1024 | 109 | // output: 1024 |
109 | 110 | ||
110 | bytes(1024); | 111 | bytes(1024); |
111 | -// output: 1024 | 112 | +// output: 1KB |
112 | ``` | 113 | ``` |
113 | 114 | ||
114 | ## License | 115 | ## License |
115 | 116 | ||
116 | [MIT](LICENSE) | 117 | [MIT](LICENSE) |
117 | 118 | ||
118 | -[downloads-image]: https://img.shields.io/npm/dm/bytes.svg | 119 | +[coveralls-image]: https://badgen.net/coveralls/c/github/visionmedia/bytes.js/master |
120 | +[coveralls-url]: https://coveralls.io/r/visionmedia/bytes.js?branch=master | ||
121 | +[downloads-image]: https://badgen.net/npm/dm/bytes | ||
119 | [downloads-url]: https://npmjs.org/package/bytes | 122 | [downloads-url]: https://npmjs.org/package/bytes |
120 | -[npm-image]: https://img.shields.io/npm/v/bytes.svg | 123 | +[npm-image]: https://badgen.net/npm/node/bytes |
121 | [npm-url]: https://npmjs.org/package/bytes | 124 | [npm-url]: https://npmjs.org/package/bytes |
122 | -[travis-image]: https://img.shields.io/travis/visionmedia/bytes.js/master.svg | 125 | +[travis-image]: https://badgen.net/travis/visionmedia/bytes.js/master |
123 | [travis-url]: https://travis-ci.org/visionmedia/bytes.js | 126 | [travis-url]: https://travis-ci.org/visionmedia/bytes.js |
124 | -[coveralls-image]: https://img.shields.io/coveralls/visionmedia/bytes.js/master.svg | ||
125 | -[coveralls-url]: https://coveralls.io/r/visionmedia/bytes.js?branch=master | ... | ... |
... | @@ -30,10 +30,11 @@ var map = { | ... | @@ -30,10 +30,11 @@ var map = { |
30 | kb: 1 << 10, | 30 | kb: 1 << 10, |
31 | mb: 1 << 20, | 31 | mb: 1 << 20, |
32 | gb: 1 << 30, | 32 | gb: 1 << 30, |
33 | - tb: ((1 << 30) * 1024) | 33 | + tb: Math.pow(1024, 4), |
34 | + pb: Math.pow(1024, 5), | ||
34 | }; | 35 | }; |
35 | 36 | ||
36 | -var parseRegExp = /^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb)$/i; | 37 | +var parseRegExp = /^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i; |
37 | 38 | ||
38 | /** | 39 | /** |
39 | * Convert the given value in bytes into a string or parse to string to an integer in bytes. | 40 | * Convert the given value in bytes into a string or parse to string to an integer in bytes. |
... | @@ -93,7 +94,9 @@ function format(value, options) { | ... | @@ -93,7 +94,9 @@ function format(value, options) { |
93 | var unit = (options && options.unit) || ''; | 94 | var unit = (options && options.unit) || ''; |
94 | 95 | ||
95 | if (!unit || !map[unit.toLowerCase()]) { | 96 | if (!unit || !map[unit.toLowerCase()]) { |
96 | - if (mag >= map.tb) { | 97 | + if (mag >= map.pb) { |
98 | + unit = 'PB'; | ||
99 | + } else if (mag >= map.tb) { | ||
97 | unit = 'TB'; | 100 | unit = 'TB'; |
98 | } else if (mag >= map.gb) { | 101 | } else if (mag >= map.gb) { |
99 | unit = 'GB'; | 102 | unit = 'GB'; | ... | ... |
1 | { | 1 | { |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | - "bytes@3.0.0", | 4 | + "bytes@3.1.0", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | - "_from": "bytes@3.0.0", | 8 | + "_from": "bytes@3.1.0", |
9 | - "_id": "bytes@3.0.0", | 9 | + "_id": "bytes@3.1.0", |
10 | "_inBundle": false, | 10 | "_inBundle": false, |
11 | - "_integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=", | 11 | + "_integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==", |
12 | "_location": "/bytes", | 12 | "_location": "/bytes", |
13 | "_phantomChildren": {}, | 13 | "_phantomChildren": {}, |
14 | "_requested": { | 14 | "_requested": { |
15 | "type": "version", | 15 | "type": "version", |
16 | "registry": true, | 16 | "registry": true, |
17 | - "raw": "bytes@3.0.0", | 17 | + "raw": "bytes@3.1.0", |
18 | "name": "bytes", | 18 | "name": "bytes", |
19 | "escapedName": "bytes", | 19 | "escapedName": "bytes", |
20 | - "rawSpec": "3.0.0", | 20 | + "rawSpec": "3.1.0", |
21 | "saveSpec": null, | 21 | "saveSpec": null, |
22 | - "fetchSpec": "3.0.0" | 22 | + "fetchSpec": "3.1.0" |
23 | }, | 23 | }, |
24 | "_requiredBy": [ | 24 | "_requiredBy": [ |
25 | "/body-parser", | 25 | "/body-parser", |
26 | "/raw-body" | 26 | "/raw-body" |
27 | ], | 27 | ], |
28 | - "_resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", | 28 | + "_resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", |
29 | - "_spec": "3.0.0", | 29 | + "_spec": "3.1.0", |
30 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 30 | + "_where": "/Users/star/Desktop/YTMT", |
31 | "author": { | 31 | "author": { |
32 | "name": "TJ Holowaychuk", | 32 | "name": "TJ Holowaychuk", |
33 | "email": "tj@vision-media.ca", | 33 | "email": "tj@vision-media.ca", |
... | @@ -48,8 +48,9 @@ | ... | @@ -48,8 +48,9 @@ |
48 | ], | 48 | ], |
49 | "description": "Utility to parse a string bytes to bytes and vice-versa", | 49 | "description": "Utility to parse a string bytes to bytes and vice-versa", |
50 | "devDependencies": { | 50 | "devDependencies": { |
51 | - "mocha": "2.5.3", | 51 | + "eslint": "5.12.1", |
52 | - "nyc": "10.3.2" | 52 | + "mocha": "5.2.0", |
53 | + "nyc": "13.1.0" | ||
53 | }, | 54 | }, |
54 | "engines": { | 55 | "engines": { |
55 | "node": ">= 0.8" | 56 | "node": ">= 0.8" |
... | @@ -77,9 +78,10 @@ | ... | @@ -77,9 +78,10 @@ |
77 | "url": "git+https://github.com/visionmedia/bytes.js.git" | 78 | "url": "git+https://github.com/visionmedia/bytes.js.git" |
78 | }, | 79 | }, |
79 | "scripts": { | 80 | "scripts": { |
81 | + "lint": "eslint .", | ||
80 | "test": "mocha --check-leaks --reporter spec", | 82 | "test": "mocha --check-leaks --reporter spec", |
81 | "test-ci": "nyc --reporter=text npm test", | 83 | "test-ci": "nyc --reporter=text npm test", |
82 | "test-cov": "nyc --reporter=html --reporter=text npm test" | 84 | "test-cov": "nyc --reporter=html --reporter=text npm test" |
83 | }, | 85 | }, |
84 | - "version": "3.0.0" | 86 | + "version": "3.1.0" |
85 | } | 87 | } | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "callsites@3.1.0", | 4 | "callsites@3.1.0", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "callsites@3.1.0", | 8 | "_from": "callsites@3.1.0", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", | 27 | "_resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", |
28 | "_spec": "3.1.0", | 28 | "_spec": "3.1.0", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "Sindre Sorhus", | 31 | "name": "Sindre Sorhus", |
32 | "email": "sindresorhus@gmail.com", | 32 | "email": "sindresorhus@gmail.com", | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "carrier@0.1.14", | 4 | "carrier@0.1.14", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "carrier@0.1.14", | 8 | "_from": "carrier@0.1.14", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/carrier/-/carrier-0.1.14.tgz", | 27 | "_resolved": "https://registry.npmjs.org/carrier/-/carrier-0.1.14.tgz", |
28 | "_spec": "0.1.14", | 28 | "_spec": "0.1.14", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "Pedro Teixeira", | 31 | "name": "Pedro Teixeira", |
32 | "email": "pedro.teixeira@gmail.com" | 32 | "email": "pedro.teixeira@gmail.com" | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "caseless@0.11.0", | 4 | "caseless@0.11.0", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "caseless@0.11.0", | 8 | "_from": "caseless@0.11.0", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz", | 27 | "_resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz", |
28 | "_spec": "0.11.0", | 28 | "_spec": "0.11.0", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "Mikeal Rogers", | 31 | "name": "Mikeal Rogers", |
32 | "email": "mikeal.rogers@gmail.com" | 32 | "email": "mikeal.rogers@gmail.com" | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "casperjs@1.1.4", | 4 | "casperjs@1.1.4", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "casperjs@1.1.4", | 8 | "_from": "casperjs@1.1.4", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/casperjs/-/casperjs-1.1.4.tgz", | 27 | "_resolved": "https://registry.npmjs.org/casperjs/-/casperjs-1.1.4.tgz", |
28 | "_spec": "1.1.4", | 28 | "_spec": "1.1.4", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "CasperJS Organization", | 31 | "name": "CasperJS Organization", |
32 | "url": "https://casperjs.org/" | 32 | "url": "https://casperjs.org/" | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "chalk@1.1.3", | 4 | "chalk@1.1.3", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "chalk@1.1.3", | 8 | "_from": "chalk@1.1.3", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", | 27 | "_resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", |
28 | "_spec": "1.1.3", | 28 | "_spec": "1.1.3", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "bugs": { | 30 | "bugs": { |
31 | "url": "https://github.com/chalk/chalk/issues" | 31 | "url": "https://github.com/chalk/chalk/issues" |
32 | }, | 32 | }, | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "async@2.6.3", | 4 | "async@2.6.3", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "async@2.6.3", | 8 | "_from": "async@2.6.3", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", | 27 | "_resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", |
28 | "_spec": "2.6.3", | 28 | "_spec": "2.6.3", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "Caolan McMahon" | 31 | "name": "Caolan McMahon" |
32 | }, | 32 | }, | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "cheerio@0.22.0", | 4 | "cheerio@0.22.0", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "cheerio@0.22.0", | 8 | "_from": "cheerio@0.22.0", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "http://registry.npmjs.org/cheerio/-/cheerio-0.22.0.tgz", | 27 | "_resolved": "http://registry.npmjs.org/cheerio/-/cheerio-0.22.0.tgz", |
28 | "_spec": "0.22.0", | 28 | "_spec": "0.22.0", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "Matt Mueller", | 31 | "name": "Matt Mueller", |
32 | "email": "mattmuelle@gmail.com", | 32 | "email": "mattmuelle@gmail.com", | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "iconv-lite@0.4.24", | 4 | "iconv-lite@0.4.24", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "iconv-lite@0.4.24", | 8 | "_from": "iconv-lite@0.4.24", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", | 27 | "_resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", |
28 | "_spec": "0.4.24", | 28 | "_spec": "0.4.24", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "Alexander Shtuchkin", | 31 | "name": "Alexander Shtuchkin", |
32 | "email": "ashtuchkin@gmail.com" | 32 | "email": "ashtuchkin@gmail.com" | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "tough-cookie@3.0.1", | 4 | "tough-cookie@3.0.1", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "tough-cookie@3.0.1", | 8 | "_from": "tough-cookie@3.0.1", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-3.0.1.tgz", | 27 | "_resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-3.0.1.tgz", |
28 | "_spec": "3.0.1", | 28 | "_spec": "3.0.1", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "Jeremy Stashewsky", | 31 | "name": "Jeremy Stashewsky", |
32 | "email": "jstash@gmail.com" | 32 | "email": "jstash@gmail.com" | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "cheerio-httpcli@0.7.4", | 4 | "cheerio-httpcli@0.7.4", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "cheerio-httpcli@0.7.4", | 8 | "_from": "cheerio-httpcli@0.7.4", |
... | @@ -48,7 +48,7 @@ | ... | @@ -48,7 +48,7 @@ |
48 | ], | 48 | ], |
49 | "_resolved": "https://registry.npmjs.org/cheerio-httpcli/-/cheerio-httpcli-0.7.4.tgz", | 49 | "_resolved": "https://registry.npmjs.org/cheerio-httpcli/-/cheerio-httpcli-0.7.4.tgz", |
50 | "_spec": "0.7.4", | 50 | "_spec": "0.7.4", |
51 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 51 | + "_where": "/Users/star/Desktop/YTMT", |
52 | "author": { | 52 | "author": { |
53 | "name": "ktty1220", | 53 | "name": "ktty1220", |
54 | "email": "ktty1220@gmail.com" | 54 | "email": "ktty1220@gmail.com" | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "cheerio@1.0.0-rc.2", | 4 | "cheerio@1.0.0-rc.2", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "cheerio@1.0.0-rc.2", | 8 | "_from": "cheerio@1.0.0-rc.2", |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | ], | 26 | ], |
27 | "_resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.2.tgz", | 27 | "_resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.2.tgz", |
28 | "_spec": "1.0.0-rc.2", | 28 | "_spec": "1.0.0-rc.2", |
29 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 29 | + "_where": "/Users/star/Desktop/YTMT", |
30 | "author": { | 30 | "author": { |
31 | "name": "Matt Mueller", | 31 | "name": "Matt Mueller", |
32 | "email": "mattmuelle@gmail.com", | 32 | "email": "mattmuelle@gmail.com", | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "colors@1.4.0", | 4 | "colors@1.4.0", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "colors@1.4.0", | 8 | "_from": "colors@1.4.0", |
... | @@ -27,7 +27,7 @@ | ... | @@ -27,7 +27,7 @@ |
27 | ], | 27 | ], |
28 | "_resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", | 28 | "_resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", |
29 | "_spec": "1.4.0", | 29 | "_spec": "1.4.0", |
30 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 30 | + "_where": "/Users/star/Desktop/YTMT", |
31 | "author": { | 31 | "author": { |
32 | "name": "Marak Squires" | 32 | "name": "Marak Squires" |
33 | }, | 33 | }, | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "_args": [ | 2 | "_args": [ |
3 | [ | 3 | [ |
4 | "combined-stream@1.0.7", | 4 | "combined-stream@1.0.7", |
5 | - "/Users/star/Desktop/OS/YTMT/YTMT" | 5 | + "/Users/star/Desktop/YTMT" |
6 | ] | 6 | ] |
7 | ], | 7 | ], |
8 | "_from": "combined-stream@1.0.7", | 8 | "_from": "combined-stream@1.0.7", |
... | @@ -29,7 +29,7 @@ | ... | @@ -29,7 +29,7 @@ |
29 | ], | 29 | ], |
30 | "_resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", | 30 | "_resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", |
31 | "_spec": "1.0.7", | 31 | "_spec": "1.0.7", |
32 | - "_where": "/Users/star/Desktop/OS/YTMT/YTMT", | 32 | + "_where": "/Users/star/Desktop/YTMT", |
33 | "author": { | 33 | "author": { |
34 | "name": "Felix Geisendörfer", | 34 | "name": "Felix Geisendörfer", |
35 | "email": "felix@debuggable.com", | 35 | "email": "felix@debuggable.com", | ... | ... |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/toidentifier/LICENSE
0 → 100644
This diff is collapsed. Click to expand it.
node_modules/toidentifier/README.md
0 → 100644
This diff is collapsed. Click to expand it.
node_modules/toidentifier/index.js
0 → 100644
This diff is collapsed. Click to expand it.
node_modules/toidentifier/package.json
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
public/stylesheets/login.css
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
routes/adduser.js
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
views/adduser.ejs
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment