moved directory
This commit is contained in:
50
node_modules/media-typer/HISTORY.md
generated
vendored
Normal file
50
node_modules/media-typer/HISTORY.md
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
1.1.0 / 2019-04-24
|
||||
==================
|
||||
|
||||
* Add `test(string)` function
|
||||
|
||||
1.0.2 / 2019-04-19
|
||||
==================
|
||||
|
||||
* Fix JSDoc comment for `parse` function
|
||||
|
||||
1.0.1 / 2018-10-20
|
||||
==================
|
||||
|
||||
* Remove left over `parameters` property from class
|
||||
|
||||
1.0.0 / 2018-10-20
|
||||
==================
|
||||
|
||||
This major release brings the module back to it's RFC 6838 roots. If you want
|
||||
a module to parse the `Content-Type` or similar HTTP headers, use the
|
||||
`content-type` module instead.
|
||||
|
||||
* Drop support for Node.js below 0.8
|
||||
* Remove parameter handling, which is outside RFC 6838 scope
|
||||
* Remove `parse(req)` and `parse(res)` signatures
|
||||
* perf: enable strict mode
|
||||
* perf: use a class for object creation
|
||||
|
||||
0.3.0 / 2014-09-07
|
||||
==================
|
||||
|
||||
* Support Node.js 0.6
|
||||
* Throw error when parameter format invalid on parse
|
||||
|
||||
0.2.0 / 2014-06-18
|
||||
==================
|
||||
|
||||
* Add `typer.format()` to format media types
|
||||
|
||||
0.1.0 / 2014-06-17
|
||||
==================
|
||||
|
||||
* Accept `req` as argument to `parse`
|
||||
* Accept `res` as argument to `parse`
|
||||
* Parse media type with extra LWS between type and first parameter
|
||||
|
||||
0.0.0 / 2014-06-13
|
||||
==================
|
||||
|
||||
* Initial implementation
|
22
node_modules/media-typer/LICENSE
generated
vendored
Normal file
22
node_modules/media-typer/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014-2017 Douglas Christopher Wilson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
93
node_modules/media-typer/README.md
generated
vendored
Normal file
93
node_modules/media-typer/README.md
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
# media-typer
|
||||
|
||||
[![NPM Version][npm-version-image]][npm-url]
|
||||
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
Simple RFC 6838 media type parser.
|
||||
|
||||
This module will parse a given media type into it's component parts, like type,
|
||||
subtype, and suffix. A formatter is also provided to put them back together and
|
||||
the two can be combined to normalize media types into a canonical form.
|
||||
|
||||
If you are looking to parse the string that represents a media type and it's
|
||||
parameters in HTTP (for example, the `Content-Type` header), use the
|
||||
[content-type module](https://www.npmjs.com/package/content-type).
|
||||
|
||||
## Installation
|
||||
|
||||
This is a [Node.js](https://nodejs.org/en/) module available through the
|
||||
[npm registry](https://www.npmjs.com/). Installation is done using the
|
||||
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
||||
|
||||
```sh
|
||||
$ npm install media-typer
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
<!-- eslint-disable no-unused-vars -->
|
||||
|
||||
```js
|
||||
var typer = require('media-typer')
|
||||
```
|
||||
|
||||
### typer.parse(string)
|
||||
|
||||
<!-- eslint-disable no-undef, no-unused-vars -->
|
||||
|
||||
```js
|
||||
var obj = typer.parse('image/svg+xml')
|
||||
```
|
||||
|
||||
Parse a media type string. This will return an object with the following
|
||||
properties (examples are shown for the string `'image/svg+xml; charset=utf-8'`):
|
||||
|
||||
- `type`: The type of the media type (always lower case). Example: `'image'`
|
||||
|
||||
- `subtype`: The subtype of the media type (always lower case). Example: `'svg'`
|
||||
|
||||
- `suffix`: The suffix of the media type (always lower case). Example: `'xml'`
|
||||
|
||||
If the given type string is invalid, then a `TypeError` is thrown.
|
||||
|
||||
### typer.format(obj)
|
||||
|
||||
<!-- eslint-disable no-undef, no-unused-vars -->
|
||||
|
||||
```js
|
||||
var obj = typer.format({ type: 'image', subtype: 'svg', suffix: 'xml' })
|
||||
```
|
||||
|
||||
Format an object into a media type string. This will return a string of the
|
||||
mime type for the given object. For the properties of the object, see the
|
||||
documentation for `typer.parse(string)`.
|
||||
|
||||
If any of the given object values are invalid, then a `TypeError` is thrown.
|
||||
|
||||
### typer.test(string)
|
||||
|
||||
<!-- eslint-disable no-undef, no-unused-vars -->
|
||||
|
||||
```js
|
||||
var valid = typer.test('image/svg+xml')
|
||||
```
|
||||
|
||||
Validate a media type string. This will return `true` is the string is a well-
|
||||
formatted media type, or `false` otherwise.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/media-typer/master
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/media-typer?branch=master
|
||||
[node-version-image]: https://badgen.net/npm/node/media-typer
|
||||
[node-version-url]: https://nodejs.org/en/download
|
||||
[npm-downloads-image]: https://badgen.net/npm/dm/media-typer
|
||||
[npm-url]: https://npmjs.org/package/media-typer
|
||||
[npm-version-image]: https://badgen.net/npm/v/media-typer
|
||||
[travis-image]: https://badgen.net/travis/jshttp/media-typer/master
|
||||
[travis-url]: https://travis-ci.org/jshttp/media-typer
|
143
node_modules/media-typer/index.js
generated
vendored
Normal file
143
node_modules/media-typer/index.js
generated
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
/*!
|
||||
* media-typer
|
||||
* Copyright(c) 2014-2017 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* RegExp to match type in RFC 6838
|
||||
*
|
||||
* type-name = restricted-name
|
||||
* subtype-name = restricted-name
|
||||
* restricted-name = restricted-name-first *126restricted-name-chars
|
||||
* restricted-name-first = ALPHA / DIGIT
|
||||
* restricted-name-chars = ALPHA / DIGIT / "!" / "#" /
|
||||
* "$" / "&" / "-" / "^" / "_"
|
||||
* restricted-name-chars =/ "." ; Characters before first dot always
|
||||
* ; specify a facet name
|
||||
* restricted-name-chars =/ "+" ; Characters after last plus always
|
||||
* ; specify a structured syntax suffix
|
||||
* ALPHA = %x41-5A / %x61-7A ; A-Z / a-z
|
||||
* DIGIT = %x30-39 ; 0-9
|
||||
*/
|
||||
var SUBTYPE_NAME_REGEXP = /^[A-Za-z0-9][A-Za-z0-9!#$&^_.-]{0,126}$/
|
||||
var TYPE_NAME_REGEXP = /^[A-Za-z0-9][A-Za-z0-9!#$&^_-]{0,126}$/
|
||||
var TYPE_REGEXP = /^ *([A-Za-z0-9][A-Za-z0-9!#$&^_-]{0,126})\/([A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}) *$/
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
exports.format = format
|
||||
exports.parse = parse
|
||||
exports.test = test
|
||||
|
||||
/**
|
||||
* Format object to media type.
|
||||
*
|
||||
* @param {object} obj
|
||||
* @return {string}
|
||||
* @public
|
||||
*/
|
||||
|
||||
function format (obj) {
|
||||
if (!obj || typeof obj !== 'object') {
|
||||
throw new TypeError('argument obj is required')
|
||||
}
|
||||
|
||||
var subtype = obj.subtype
|
||||
var suffix = obj.suffix
|
||||
var type = obj.type
|
||||
|
||||
if (!type || !TYPE_NAME_REGEXP.test(type)) {
|
||||
throw new TypeError('invalid type')
|
||||
}
|
||||
|
||||
if (!subtype || !SUBTYPE_NAME_REGEXP.test(subtype)) {
|
||||
throw new TypeError('invalid subtype')
|
||||
}
|
||||
|
||||
// format as type/subtype
|
||||
var string = type + '/' + subtype
|
||||
|
||||
// append +suffix
|
||||
if (suffix) {
|
||||
if (!TYPE_NAME_REGEXP.test(suffix)) {
|
||||
throw new TypeError('invalid suffix')
|
||||
}
|
||||
|
||||
string += '+' + suffix
|
||||
}
|
||||
|
||||
return string
|
||||
}
|
||||
|
||||
/**
|
||||
* Test media type.
|
||||
*
|
||||
* @param {string} string
|
||||
* @return {object}
|
||||
* @public
|
||||
*/
|
||||
|
||||
function test (string) {
|
||||
if (!string) {
|
||||
throw new TypeError('argument string is required')
|
||||
}
|
||||
|
||||
if (typeof string !== 'string') {
|
||||
throw new TypeError('argument string is required to be a string')
|
||||
}
|
||||
|
||||
return TYPE_REGEXP.test(string.toLowerCase())
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse media type to object.
|
||||
*
|
||||
* @param {string} string
|
||||
* @return {object}
|
||||
* @public
|
||||
*/
|
||||
|
||||
function parse (string) {
|
||||
if (!string) {
|
||||
throw new TypeError('argument string is required')
|
||||
}
|
||||
|
||||
if (typeof string !== 'string') {
|
||||
throw new TypeError('argument string is required to be a string')
|
||||
}
|
||||
|
||||
var match = TYPE_REGEXP.exec(string.toLowerCase())
|
||||
|
||||
if (!match) {
|
||||
throw new TypeError('invalid media type')
|
||||
}
|
||||
|
||||
var type = match[1]
|
||||
var subtype = match[2]
|
||||
var suffix
|
||||
|
||||
// suffix after last +
|
||||
var index = subtype.lastIndexOf('+')
|
||||
if (index !== -1) {
|
||||
suffix = subtype.substr(index + 1)
|
||||
subtype = subtype.substr(0, index)
|
||||
}
|
||||
|
||||
return new MediaType(type, subtype, suffix)
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for MediaType object.
|
||||
* @public
|
||||
*/
|
||||
|
||||
function MediaType (type, subtype, suffix) {
|
||||
this.type = type
|
||||
this.subtype = subtype
|
||||
this.suffix = suffix
|
||||
}
|
33
node_modules/media-typer/package.json
generated
vendored
Normal file
33
node_modules/media-typer/package.json
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "media-typer",
|
||||
"description": "Simple RFC 6838 media type parser and formatter",
|
||||
"version": "1.1.0",
|
||||
"author": "Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||
"license": "MIT",
|
||||
"repository": "jshttp/media-typer",
|
||||
"devDependencies": {
|
||||
"eslint": "5.16.0",
|
||||
"eslint-config-standard": "12.0.0",
|
||||
"eslint-plugin-import": "2.17.2",
|
||||
"eslint-plugin-markdown": "1.0.0",
|
||||
"eslint-plugin-node": "8.0.1",
|
||||
"eslint-plugin-promise": "4.1.1",
|
||||
"eslint-plugin-standard": "4.0.0",
|
||||
"mocha": "6.1.4",
|
||||
"nyc": "14.0.0"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"HISTORY.md",
|
||||
"index.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint --plugin markdown --ext js,md .",
|
||||
"test": "mocha --reporter spec --check-leaks --bail test/",
|
||||
"test-cov": "nyc --reporter=html --reporter=text npm test",
|
||||
"test-travis": "nyc --reporter=text npm test"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user