moved directory
This commit is contained in:
421
node_modules/mime-types/HISTORY.md
generated
vendored
Normal file
421
node_modules/mime-types/HISTORY.md
generated
vendored
Normal file
@@ -0,0 +1,421 @@
|
||||
3.0.1 / 2025-03-26
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.54.0
|
||||
|
||||
3.0.0 / 2024-08-31
|
||||
===================
|
||||
|
||||
* Drop support for node <18
|
||||
* deps: mime-db@1.53.0
|
||||
* resolve extension conflicts with mime-score (#119)
|
||||
* asc -> application/pgp-signature is now application/pgp-keys
|
||||
* mpp -> application/vnd.ms-project is now application/dash-patch+xml
|
||||
* ac -> application/vnd.nokia.n-gage.ac+xml is now application/pkix-attr-cert
|
||||
* bdoc -> application/x-bdoc is now application/bdoc
|
||||
* wmz -> application/x-msmetafile is now application/x-ms-wmz
|
||||
* xsl -> application/xslt+xml is now application/xml
|
||||
* wav -> audio/wave is now audio/wav
|
||||
* rtf -> text/rtf is now application/rtf
|
||||
* xml -> text/xml is now application/xml
|
||||
* mp4 -> video/mp4 is now application/mp4
|
||||
* mpg4 -> video/mp4 is now application/mp4
|
||||
|
||||
|
||||
2.1.35 / 2022-03-12
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.52.0
|
||||
- Add extensions from IANA for more `image/*` types
|
||||
- Add extension `.asc` to `application/pgp-keys`
|
||||
- Add extensions to various XML types
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.34 / 2021-11-08
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.51.0
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.33 / 2021-10-01
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.50.0
|
||||
- Add deprecated iWorks mime types and extensions
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.32 / 2021-07-27
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.49.0
|
||||
- Add extension `.trig` to `application/trig`
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.31 / 2021-06-01
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.48.0
|
||||
- Add extension `.mvt` to `application/vnd.mapbox-vector-tile`
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.30 / 2021-04-02
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.47.0
|
||||
- Add extension `.amr` to `audio/amr`
|
||||
- Remove ambigious extensions from IANA for `application/*+xml` types
|
||||
- Update primary extension to `.es` for `application/ecmascript`
|
||||
|
||||
2.1.29 / 2021-02-17
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.46.0
|
||||
- Add extension `.amr` to `audio/amr`
|
||||
- Add extension `.m4s` to `video/iso.segment`
|
||||
- Add extension `.opus` to `audio/ogg`
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.28 / 2021-01-01
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.45.0
|
||||
- Add `application/ubjson` with extension `.ubj`
|
||||
- Add `image/avif` with extension `.avif`
|
||||
- Add `image/ktx2` with extension `.ktx2`
|
||||
- Add extension `.dbf` to `application/vnd.dbf`
|
||||
- Add extension `.rar` to `application/vnd.rar`
|
||||
- Add extension `.td` to `application/urc-targetdesc+xml`
|
||||
- Add new upstream MIME types
|
||||
- Fix extension of `application/vnd.apple.keynote` to be `.key`
|
||||
|
||||
2.1.27 / 2020-04-23
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.44.0
|
||||
- Add charsets from IANA
|
||||
- Add extension `.cjs` to `application/node`
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.26 / 2020-01-05
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.43.0
|
||||
- Add `application/x-keepass2` with extension `.kdbx`
|
||||
- Add extension `.mxmf` to `audio/mobile-xmf`
|
||||
- Add extensions from IANA for `application/*+xml` types
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.25 / 2019-11-12
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.42.0
|
||||
- Add new upstream MIME types
|
||||
- Add `application/toml` with extension `.toml`
|
||||
- Add `image/vnd.ms-dds` with extension `.dds`
|
||||
|
||||
2.1.24 / 2019-04-20
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.40.0
|
||||
- Add extensions from IANA for `model/*` types
|
||||
- Add `text/mdx` with extension `.mdx`
|
||||
|
||||
2.1.23 / 2019-04-17
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.39.0
|
||||
- Add extensions `.siv` and `.sieve` to `application/sieve`
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.22 / 2019-02-14
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.38.0
|
||||
- Add extension `.nq` to `application/n-quads`
|
||||
- Add extension `.nt` to `application/n-triples`
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.21 / 2018-10-19
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.37.0
|
||||
- Add extensions to HEIC image types
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.20 / 2018-08-26
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.36.0
|
||||
- Add Apple file extensions from IANA
|
||||
- Add extensions from IANA for `image/*` types
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.19 / 2018-07-17
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.35.0
|
||||
- Add extension `.csl` to `application/vnd.citationstyles.style+xml`
|
||||
- Add extension `.es` to `application/ecmascript`
|
||||
- Add extension `.owl` to `application/rdf+xml`
|
||||
- Add new upstream MIME types
|
||||
- Add UTF-8 as default charset for `text/turtle`
|
||||
|
||||
2.1.18 / 2018-02-16
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.33.0
|
||||
- Add `application/raml+yaml` with extension `.raml`
|
||||
- Add `application/wasm` with extension `.wasm`
|
||||
- Add `text/shex` with extension `.shex`
|
||||
- Add extensions for JPEG-2000 images
|
||||
- Add extensions from IANA for `message/*` types
|
||||
- Add new upstream MIME types
|
||||
- Update font MIME types
|
||||
- Update `text/hjson` to registered `application/hjson`
|
||||
|
||||
2.1.17 / 2017-09-01
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.30.0
|
||||
- Add `application/vnd.ms-outlook`
|
||||
- Add `application/x-arj`
|
||||
- Add extension `.mjs` to `application/javascript`
|
||||
- Add glTF types and extensions
|
||||
- Add new upstream MIME types
|
||||
- Add `text/x-org`
|
||||
- Add VirtualBox MIME types
|
||||
- Fix `source` records for `video/*` types that are IANA
|
||||
- Update `font/opentype` to registered `font/otf`
|
||||
|
||||
2.1.16 / 2017-07-24
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.29.0
|
||||
- Add `application/fido.trusted-apps+json`
|
||||
- Add extension `.wadl` to `application/vnd.sun.wadl+xml`
|
||||
- Add extension `.gz` to `application/gzip`
|
||||
- Add new upstream MIME types
|
||||
- Update extensions `.md` and `.markdown` to be `text/markdown`
|
||||
|
||||
2.1.15 / 2017-03-23
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.27.0
|
||||
- Add new mime types
|
||||
- Add `image/apng`
|
||||
|
||||
2.1.14 / 2017-01-14
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.26.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.13 / 2016-11-18
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.25.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.12 / 2016-09-18
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.24.0
|
||||
- Add new mime types
|
||||
- Add `audio/mp3`
|
||||
|
||||
2.1.11 / 2016-05-01
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.23.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.10 / 2016-02-15
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.22.0
|
||||
- Add new mime types
|
||||
- Fix extension of `application/dash+xml`
|
||||
- Update primary extension for `audio/mp4`
|
||||
|
||||
2.1.9 / 2016-01-06
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.21.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.8 / 2015-11-30
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.20.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.7 / 2015-09-20
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.19.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.6 / 2015-09-03
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.18.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.5 / 2015-08-20
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.17.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.4 / 2015-07-30
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.16.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.3 / 2015-07-13
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.15.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.2 / 2015-06-25
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.14.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.1 / 2015-06-08
|
||||
==================
|
||||
|
||||
* perf: fix deopt during mapping
|
||||
|
||||
2.1.0 / 2015-06-07
|
||||
==================
|
||||
|
||||
* Fix incorrectly treating extension-less file name as extension
|
||||
- i.e. `'path/to/json'` will no longer return `application/json`
|
||||
* Fix `.charset(type)` to accept parameters
|
||||
* Fix `.charset(type)` to match case-insensitive
|
||||
* Improve generation of extension to MIME mapping
|
||||
* Refactor internals for readability and no argument reassignment
|
||||
* Prefer `application/*` MIME types from the same source
|
||||
* Prefer any type over `application/octet-stream`
|
||||
* deps: mime-db@~1.13.0
|
||||
- Add nginx as a source
|
||||
- Add new mime types
|
||||
|
||||
2.0.14 / 2015-06-06
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.12.0
|
||||
- Add new mime types
|
||||
|
||||
2.0.13 / 2015-05-31
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.11.0
|
||||
- Add new mime types
|
||||
|
||||
2.0.12 / 2015-05-19
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.10.0
|
||||
- Add new mime types
|
||||
|
||||
2.0.11 / 2015-05-05
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.9.1
|
||||
- Add new mime types
|
||||
|
||||
2.0.10 / 2015-03-13
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.8.0
|
||||
- Add new mime types
|
||||
|
||||
2.0.9 / 2015-02-09
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.7.0
|
||||
- Add new mime types
|
||||
- Community extensions ownership transferred from `node-mime`
|
||||
|
||||
2.0.8 / 2015-01-29
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.6.0
|
||||
- Add new mime types
|
||||
|
||||
2.0.7 / 2014-12-30
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.5.0
|
||||
- Add new mime types
|
||||
- Fix various invalid MIME type entries
|
||||
|
||||
2.0.6 / 2014-12-30
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.4.0
|
||||
- Add new mime types
|
||||
- Fix various invalid MIME type entries
|
||||
- Remove example template MIME types
|
||||
|
||||
2.0.5 / 2014-12-29
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.3.1
|
||||
- Fix missing extensions
|
||||
|
||||
2.0.4 / 2014-12-10
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.3.0
|
||||
- Add new mime types
|
||||
|
||||
2.0.3 / 2014-11-09
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.2.0
|
||||
- Add new mime types
|
||||
|
||||
2.0.2 / 2014-09-28
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.1.0
|
||||
- Add new mime types
|
||||
- Update charsets
|
||||
|
||||
2.0.1 / 2014-09-07
|
||||
==================
|
||||
|
||||
* Support Node.js 0.6
|
||||
|
||||
2.0.0 / 2014-09-02
|
||||
==================
|
||||
|
||||
* Use `mime-db`
|
||||
* Remove `.define()`
|
||||
|
||||
1.0.2 / 2014-08-04
|
||||
==================
|
||||
|
||||
* Set charset=utf-8 for `text/javascript`
|
||||
|
||||
1.0.1 / 2014-06-24
|
||||
==================
|
||||
|
||||
* Add `text/jsx` type
|
||||
|
||||
1.0.0 / 2014-05-12
|
||||
==================
|
||||
|
||||
* Return `false` for unknown types
|
||||
* Set charset=utf-8 for `application/json`
|
||||
|
||||
0.1.0 / 2014-05-02
|
||||
==================
|
||||
|
||||
* Initial release
|
23
node_modules/mime-types/LICENSE
generated
vendored
Normal file
23
node_modules/mime-types/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
|
||||
Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
|
||||
|
||||
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.
|
126
node_modules/mime-types/README.md
generated
vendored
Normal file
126
node_modules/mime-types/README.md
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
# mime-types
|
||||
|
||||
[![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][ci-image]][ci-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
The ultimate javascript content-type utility.
|
||||
|
||||
Similar to [the `mime@1.x` module](https://www.npmjs.com/package/mime), except:
|
||||
|
||||
- __No fallbacks.__ Instead of naively returning the first available type,
|
||||
`mime-types` simply returns `false`, so do
|
||||
`var type = mime.lookup('unrecognized') || 'application/octet-stream'`.
|
||||
- No `new Mime()` business, so you could do `var lookup = require('mime-types').lookup`.
|
||||
- No `.define()` functionality
|
||||
- Bug fixes for `.lookup(path)`
|
||||
|
||||
Otherwise, the API is compatible with `mime` 1.x.
|
||||
|
||||
## Install
|
||||
|
||||
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 mime-types
|
||||
```
|
||||
|
||||
## Note on MIME Type Data and Semver
|
||||
|
||||
This package considers the programmatic api as the semver compatibility. Additionally, the package which provides the MIME data
|
||||
for this package (`mime-db`) *also* considers it's programmatic api as the semver contract. This means the MIME type resolution is *not* considered
|
||||
in the semver bumps.
|
||||
|
||||
In the past the version of `mime-db` was pinned to give two decision points when adopting MIME data changes. This is no longer true. We still update the
|
||||
`mime-db` package here as a `minor` release when necessary, but will use a `^` range going forward. This means that if you want to pin your `mime-db` data
|
||||
you will need to do it in your application. While this expectation was not set in docs until now, it is how the pacakge operated, so we do not feel this is
|
||||
a breaking change.
|
||||
|
||||
If you wish to pin your `mime-db` version you can do that with overrides via your package manager of choice. See their documentation for how to correctly configure that.
|
||||
|
||||
## Adding Types
|
||||
|
||||
All mime types are based on [mime-db](https://www.npmjs.com/package/mime-db),
|
||||
so open a PR there if you'd like to add mime types.
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var mime = require('mime-types')
|
||||
```
|
||||
|
||||
All functions return `false` if input is invalid or not found.
|
||||
|
||||
### mime.lookup(path)
|
||||
|
||||
Lookup the content-type associated with a file.
|
||||
|
||||
```js
|
||||
mime.lookup('json') // 'application/json'
|
||||
mime.lookup('.md') // 'text/markdown'
|
||||
mime.lookup('file.html') // 'text/html'
|
||||
mime.lookup('folder/file.js') // 'application/javascript'
|
||||
mime.lookup('folder/.htaccess') // false
|
||||
|
||||
mime.lookup('cats') // false
|
||||
```
|
||||
|
||||
### mime.contentType(type)
|
||||
|
||||
Create a full content-type header given a content-type or extension.
|
||||
When given an extension, `mime.lookup` is used to get the matching
|
||||
content-type, otherwise the given content-type is used. Then if the
|
||||
content-type does not already have a `charset` parameter, `mime.charset`
|
||||
is used to get the default charset and add to the returned content-type.
|
||||
|
||||
```js
|
||||
mime.contentType('markdown') // 'text/x-markdown; charset=utf-8'
|
||||
mime.contentType('file.json') // 'application/json; charset=utf-8'
|
||||
mime.contentType('text/html') // 'text/html; charset=utf-8'
|
||||
mime.contentType('text/html; charset=iso-8859-1') // 'text/html; charset=iso-8859-1'
|
||||
|
||||
// from a full path
|
||||
mime.contentType(path.extname('/path/to/file.json')) // 'application/json; charset=utf-8'
|
||||
```
|
||||
|
||||
### mime.extension(type)
|
||||
|
||||
Get the default extension for a content-type.
|
||||
|
||||
```js
|
||||
mime.extension('application/octet-stream') // 'bin'
|
||||
```
|
||||
|
||||
### mime.charset(type)
|
||||
|
||||
Lookup the implied default charset of a content-type.
|
||||
|
||||
```js
|
||||
mime.charset('text/markdown') // 'UTF-8'
|
||||
```
|
||||
|
||||
### var type = mime.types[extension]
|
||||
|
||||
A map of content-types by extension.
|
||||
|
||||
### [extensions...] = mime.extensions[type]
|
||||
|
||||
A map of extensions by content-type.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[ci-image]: https://badgen.net/github/checks/jshttp/mime-types/master?label=ci
|
||||
[ci-url]: https://github.com/jshttp/mime-types/actions/workflows/ci.yml
|
||||
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/mime-types/master
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/mime-types?branch=master
|
||||
[node-version-image]: https://badgen.net/npm/node/mime-types
|
||||
[node-version-url]: https://nodejs.org/en/download
|
||||
[npm-downloads-image]: https://badgen.net/npm/dm/mime-types
|
||||
[npm-url]: https://npmjs.org/package/mime-types
|
||||
[npm-version-image]: https://badgen.net/npm/v/mime-types
|
211
node_modules/mime-types/index.js
generated
vendored
Normal file
211
node_modules/mime-types/index.js
generated
vendored
Normal file
@@ -0,0 +1,211 @@
|
||||
/*!
|
||||
* mime-types
|
||||
* Copyright(c) 2014 Jonathan Ong
|
||||
* Copyright(c) 2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var db = require('mime-db')
|
||||
var extname = require('path').extname
|
||||
var mimeScore = require('./mimeScore')
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/
|
||||
var TEXT_TYPE_REGEXP = /^text\//i
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
exports.charset = charset
|
||||
exports.charsets = { lookup: charset }
|
||||
exports.contentType = contentType
|
||||
exports.extension = extension
|
||||
exports.extensions = Object.create(null)
|
||||
exports.lookup = lookup
|
||||
exports.types = Object.create(null)
|
||||
exports._extensionConflicts = []
|
||||
|
||||
// Populate the extensions/types maps
|
||||
populateMaps(exports.extensions, exports.types)
|
||||
|
||||
/**
|
||||
* Get the default charset for a MIME type.
|
||||
*
|
||||
* @param {string} type
|
||||
* @return {boolean|string}
|
||||
*/
|
||||
|
||||
function charset (type) {
|
||||
if (!type || typeof type !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
// TODO: use media-typer
|
||||
var match = EXTRACT_TYPE_REGEXP.exec(type)
|
||||
var mime = match && db[match[1].toLowerCase()]
|
||||
|
||||
if (mime && mime.charset) {
|
||||
return mime.charset
|
||||
}
|
||||
|
||||
// default text/* to utf-8
|
||||
if (match && TEXT_TYPE_REGEXP.test(match[1])) {
|
||||
return 'UTF-8'
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a full Content-Type header given a MIME type or extension.
|
||||
*
|
||||
* @param {string} str
|
||||
* @return {boolean|string}
|
||||
*/
|
||||
|
||||
function contentType (str) {
|
||||
// TODO: should this even be in this module?
|
||||
if (!str || typeof str !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
var mime = str.indexOf('/') === -1 ? exports.lookup(str) : str
|
||||
|
||||
if (!mime) {
|
||||
return false
|
||||
}
|
||||
|
||||
// TODO: use content-type or other module
|
||||
if (mime.indexOf('charset') === -1) {
|
||||
var charset = exports.charset(mime)
|
||||
if (charset) mime += '; charset=' + charset.toLowerCase()
|
||||
}
|
||||
|
||||
return mime
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default extension for a MIME type.
|
||||
*
|
||||
* @param {string} type
|
||||
* @return {boolean|string}
|
||||
*/
|
||||
|
||||
function extension (type) {
|
||||
if (!type || typeof type !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
// TODO: use media-typer
|
||||
var match = EXTRACT_TYPE_REGEXP.exec(type)
|
||||
|
||||
// get extensions
|
||||
var exts = match && exports.extensions[match[1].toLowerCase()]
|
||||
|
||||
if (!exts || !exts.length) {
|
||||
return false
|
||||
}
|
||||
|
||||
return exts[0]
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup the MIME type for a file path/extension.
|
||||
*
|
||||
* @param {string} path
|
||||
* @return {boolean|string}
|
||||
*/
|
||||
|
||||
function lookup (path) {
|
||||
if (!path || typeof path !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
// get the extension ("ext" or ".ext" or full path)
|
||||
var extension = extname('x.' + path)
|
||||
.toLowerCase()
|
||||
.slice(1)
|
||||
|
||||
if (!extension) {
|
||||
return false
|
||||
}
|
||||
|
||||
return exports.types[extension] || false
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the extensions and types maps.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function populateMaps (extensions, types) {
|
||||
Object.keys(db).forEach(function forEachMimeType (type) {
|
||||
var mime = db[type]
|
||||
var exts = mime.extensions
|
||||
|
||||
if (!exts || !exts.length) {
|
||||
return
|
||||
}
|
||||
|
||||
// mime -> extensions
|
||||
extensions[type] = exts
|
||||
|
||||
// extension -> mime
|
||||
for (var i = 0; i < exts.length; i++) {
|
||||
var extension = exts[i]
|
||||
types[extension] = _preferredType(extension, types[extension], type)
|
||||
|
||||
// DELETE (eventually): Capture extension->type maps that change as a
|
||||
// result of switching to mime-score. This is just to help make reviewing
|
||||
// PR #119 easier, and can be removed once that PR is approved.
|
||||
const legacyType = _preferredTypeLegacy(
|
||||
extension,
|
||||
types[extension],
|
||||
type
|
||||
)
|
||||
if (legacyType !== types[extension]) {
|
||||
exports._extensionConflicts.push([extension, legacyType, types[extension]])
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Resolve type conflict using mime-score
|
||||
function _preferredType (ext, type0, type1) {
|
||||
var score0 = type0 ? mimeScore(type0, db[type0].source) : 0
|
||||
var score1 = type1 ? mimeScore(type1, db[type1].source) : 0
|
||||
|
||||
return score0 > score1 ? type0 : type1
|
||||
}
|
||||
|
||||
// Resolve type conflict using pre-mime-score logic
|
||||
function _preferredTypeLegacy (ext, type0, type1) {
|
||||
var SOURCE_RANK = ['nginx', 'apache', undefined, 'iana']
|
||||
|
||||
var score0 = type0 ? SOURCE_RANK.indexOf(db[type0].source) : 0
|
||||
var score1 = type1 ? SOURCE_RANK.indexOf(db[type1].source) : 0
|
||||
|
||||
if (
|
||||
exports.types[extension] !== 'application/octet-stream' &&
|
||||
(score0 > score1 ||
|
||||
(score0 === score1 &&
|
||||
exports.types[extension]?.slice(0, 12) === 'application/'))
|
||||
) {
|
||||
return type0
|
||||
}
|
||||
|
||||
return score0 > score1 ? type0 : type1
|
||||
}
|
52
node_modules/mime-types/mimeScore.js
generated
vendored
Normal file
52
node_modules/mime-types/mimeScore.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
// 'mime-score' back-ported to CommonJS
|
||||
|
||||
// Score RFC facets (see https://tools.ietf.org/html/rfc6838#section-3)
|
||||
var FACET_SCORES = {
|
||||
'prs.': 100,
|
||||
'x-': 200,
|
||||
'x.': 300,
|
||||
'vnd.': 400,
|
||||
default: 900
|
||||
}
|
||||
|
||||
// Score mime source (Logic originally from `jshttp/mime-types` module)
|
||||
var SOURCE_SCORES = {
|
||||
nginx: 10,
|
||||
apache: 20,
|
||||
iana: 40,
|
||||
default: 30 // definitions added by `jshttp/mime-db` project?
|
||||
}
|
||||
|
||||
var TYPE_SCORES = {
|
||||
// prefer application/xml over text/xml
|
||||
// prefer application/rtf over text/rtf
|
||||
application: 1,
|
||||
|
||||
// prefer font/woff over application/font-woff
|
||||
font: 2,
|
||||
|
||||
default: 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Get each component of the score for a mime type. The sum of these is the
|
||||
* total score. The higher the score, the more "official" the type.
|
||||
*/
|
||||
module.exports = function mimeScore (mimeType, source = 'default') {
|
||||
if (mimeType === 'application/octet-stream') {
|
||||
return 0
|
||||
}
|
||||
|
||||
const [type, subtype] = mimeType.split('/')
|
||||
|
||||
const facet = subtype.replace(/(\.|x-).*/, '$1')
|
||||
|
||||
const facetScore = FACET_SCORES[facet] || FACET_SCORES.default
|
||||
const sourceScore = SOURCE_SCORES[source] || SOURCE_SCORES.default
|
||||
const typeScore = TYPE_SCORES[type] || TYPE_SCORES.default
|
||||
|
||||
// All else being equal prefer shorter types
|
||||
const lengthScore = 1 - mimeType.length / 100
|
||||
|
||||
return facetScore + sourceScore + typeScore + lengthScore
|
||||
}
|
45
node_modules/mime-types/package.json
generated
vendored
Normal file
45
node_modules/mime-types/package.json
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "mime-types",
|
||||
"description": "The ultimate javascript content-type utility.",
|
||||
"version": "3.0.1",
|
||||
"contributors": [
|
||||
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||
"Jeremiah Senkpiel <fishrock123@rocketmail.com> (https://searchbeam.jit.su)",
|
||||
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
|
||||
],
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"mime",
|
||||
"types"
|
||||
],
|
||||
"repository": "jshttp/mime-types",
|
||||
"dependencies": {
|
||||
"mime-db": "^1.54.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "8.33.0",
|
||||
"eslint-config-standard": "14.1.1",
|
||||
"eslint-plugin-import": "2.27.5",
|
||||
"eslint-plugin-markdown": "3.0.0",
|
||||
"eslint-plugin-node": "11.1.0",
|
||||
"eslint-plugin-promise": "6.1.1",
|
||||
"eslint-plugin-standard": "4.1.0",
|
||||
"mocha": "10.2.0",
|
||||
"nyc": "15.1.0"
|
||||
},
|
||||
"files": [
|
||||
"HISTORY.md",
|
||||
"LICENSE",
|
||||
"index.js",
|
||||
"mimeScore.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"test": "mocha --reporter spec test/test.js",
|
||||
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
||||
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user