Commit 24be6fd0 authored by Leo Iannacone's avatar Leo Iannacone

update internal libs

parent 3594c180
1.1.0 / 2014-06-16
==================
* Display error on console formatted like `throw`
* Escape HTML with `escape-html` module
* Escape HTML in stack trace
* Escape HTML in title
* Fix up edge cases with error sent in response
* Set `X-Content-Type-Options: nosniff` header
* Use accepts for negotiation
1.0.2 / 2014-06-05
==================
......
......@@ -9,16 +9,9 @@
* Module dependencies.
*/
var fs;
try {
fs = require('graceful-fs');
} catch (_) {
fs = require('fs');
}
// environment
var env = process.env.NODE_ENV || 'development';
var accepts = require('accepts')
var escapeHtml = require('escape-html');
var fs = require('fs');
/**
* Error handler:
......@@ -46,33 +39,58 @@ var env = process.env.NODE_ENV || 'development';
*/
exports = module.exports = function errorHandler(){
// get environment
var env = process.env.NODE_ENV || 'development'
return function errorHandler(err, req, res, next){
if (err.status) res.statusCode = err.status;
if (res.statusCode < 400) res.statusCode = 500;
if ('test' != env) console.error(err.stack);
if (res._header) return;
var accept = req.headers.accept || '';
// respect err.status
if (err.status) {
res.statusCode = err.status
}
// default status code to 500
if (res.statusCode < 400) {
res.statusCode = 500
}
// write error to console
if (env !== 'test') {
console.error(err.stack || String(err))
}
// cannot actually respond
if (res._header) {
return req.socket.destroy()
}
// negotiate
var accept = accepts(req)
var type = accept.types('html', 'json', 'text')
// Security header for content sniffing
res.setHeader('X-Content-Type-Options', 'nosniff')
// html
if (~accept.indexOf('html')) {
if (type === 'html') {
fs.readFile(__dirname + '/public/style.css', 'utf8', function(e, style){
if (e) return next(e);
fs.readFile(__dirname + '/public/error.html', 'utf8', function(e, html){
if (e) return next(e);
var stack = (err.stack || '')
.split('\n').slice(1)
.map(function(v){ return '<li>' + v + '</li>'; }).join('');
.map(function(v){ return '<li>' + escapeHtml(v).replace(/ /g, ' &nbsp;') + '</li>'; }).join('');
html = html
.replace('{style}', style)
.replace('{stack}', stack)
.replace('{title}', exports.title)
.replace('{title}', escapeHtml(exports.title))
.replace('{statusCode}', res.statusCode)
.replace(/\{error\}/g, escapeHTML(err.toString().replace(/\n/g, '<br/>')));
.replace(/\{error\}/g, escapeHtml(String(err)).replace(/ /g, ' &nbsp;').replace(/\n/g, '<br>'));
res.setHeader('Content-Type', 'text/html; charset=utf-8');
res.end(html);
});
});
// json
} else if (~accept.indexOf('json')) {
} else if (type === 'json') {
var error = { message: err.message, stack: err.stack };
for (var prop in err) error[prop] = err[prop];
var json = JSON.stringify({ error: error });
......@@ -81,7 +99,7 @@ exports = module.exports = function errorHandler(){
// plain text
} else {
res.setHeader('Content-Type', 'text/plain');
res.end(err.stack);
res.end(err.stack || String(err));
}
};
};
......@@ -91,20 +109,3 @@ exports = module.exports = function errorHandler(){
*/
exports.title = 'Connect';
/**
* Escape the given string of `html`.
*
* @param {String} html
* @return {String}
* @api private
*/
function escapeHTML(html){
return String(html)
.replace(/&(?!\w+;)/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
};
\ No newline at end of file
1.0.3 / 2014-06-11
==================
* deps: negotiator@0.4.6
- Order by specificity when quality is the same
1.0.2 / 2014-05-29
==================
* Fix interpretation when header not in request
* deps: pin negotiator@0.4.5
1.0.1 / 2014-01-18
==================
* Identity encoding isn't always acceptable
* deps: negotiator@~0.4.0
1.0.0 / 2013-12-27
==================
* Genesis
# Accepts
[![NPM version](https://badge.fury.io/js/accepts.svg)](http://badge.fury.io/js/accepts)
[![Build Status](https://travis-ci.org/expressjs/accepts.svg?branch=master)](https://travis-ci.org/expressjs/accepts)
[![Coverage Status](https://img.shields.io/coveralls/expressjs/accepts.svg?branch=master)](https://coveralls.io/r/expressjs/accepts)
Higher level content negotation based on [negotiator](https://github.com/federomero/negotiator). Extracted from [koa](https://github.com/koajs/koa) for general use.
In addition to negotatior, it allows:
- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])` as well as `('text/html', 'application/json')`.
- Allows type shorthands such as `json`.
- Returns `false` when no types match
- Treats non-existent headers as `*`
## API
### var accept = new Accepts(req)
```js
var accepts = require('accepts')
http.createServer(function (req, res) {
var accept = accepts(req)
})
```
### accept\[property\]\(\)
Returns all the explicitly accepted content property as an array in descending priority.
- `accept.types()`
- `accept.encodings()`
- `accept.charsets()`
- `accept.languages()`
They are also aliased in singular form such as `accept.type()`. `accept.languages()` is also aliased as `accept.langs()`, etc.
Note: you should almost never do this in a real app as it defeats the purpose of content negotiation.
Example:
```js
// in Google Chrome
var encodings = accept.encodings() // -> ['sdch', 'gzip', 'deflate']
```
Since you probably don't support `sdch`, you should just supply the encodings you support:
```js
var encoding = accept.encodings('gzip', 'deflate') // -> 'gzip', probably
```
### accept\[property\]\(values, ...\)
You can either have `values` be an array or have an argument list of values.
If the client does not accept any `values`, `false` will be returned.
If the client accepts any `values`, the preferred `value` will be return.
For `accept.types()`, shorthand mime types are allowed.
Example:
```js
// req.headers.accept = 'application/json'
accept.types('json') // -> 'json'
accept.types('html', 'json') // -> 'json'
accept.types('html') // -> false
// req.headers.accept = ''
// which is equivalent to `*`
accept.types() // -> [], no explicit types
accept.types('text/html', 'text/json') // -> 'text/html', since it was first
```
## License
The MIT License (MIT)
Copyright (c) 2013 Jonathan Ong me@jongleberry.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.
\ No newline at end of file
var Negotiator = require('negotiator')
var mime = require('mime')
var slice = [].slice
module.exports = Accepts
function Accepts(req) {
if (!(this instanceof Accepts))
return new Accepts(req)
this.headers = req.headers
this.negotiator = Negotiator(req)
}
/**
* Check if the given `type(s)` is acceptable, returning
* the best match when true, otherwise `undefined`, in which
* case you should respond with 406 "Not Acceptable".
*
* The `type` value may be a single mime type string
* such as "application/json", the extension name
* such as "json" or an array `["json", "html", "text/plain"]`. When a list
* or array is given the _best_ match, if any is returned.
*
* Examples:
*
* // Accept: text/html
* this.types('html');
* // => "html"
*
* // Accept: text/*, application/json
* this.types('html');
* // => "html"
* this.types('text/html');
* // => "text/html"
* this.types('json', 'text');
* // => "json"
* this.types('application/json');
* // => "application/json"
*
* // Accept: text/*, application/json
* this.types('image/png');
* this.types('png');
* // => undefined
*
* // Accept: text/*;q=.5, application/json
* this.types(['html', 'json']);
* this.types('html', 'json');
* // => "json"
*
* @param {String|Array} type(s)...
* @return {String|Array|Boolean}
* @api public
*/
Accepts.prototype.type =
Accepts.prototype.types = function (types) {
if (!Array.isArray(types)) types = slice.call(arguments);
var n = this.negotiator;
if (!types.length) return n.mediaTypes();
if (!this.headers.accept) return types[0];
var mimes = types.map(extToMime);
var accepts = n.mediaTypes(mimes);
var first = accepts[0];
if (!first) return false;
return types[mimes.indexOf(first)];
}
/**
* Return accepted encodings or best fit based on `encodings`.
*
* Given `Accept-Encoding: gzip, deflate`
* an array sorted by quality is returned:
*
* ['gzip', 'deflate']
*
* @param {String|Array} encoding(s)...
* @return {String|Array}
* @api public
*/
Accepts.prototype.encoding =
Accepts.prototype.encodings = function (encodings) {
if (!Array.isArray(encodings)) encodings = slice.call(arguments);
var n = this.negotiator;
if (!encodings.length) return n.encodings();
return n.encodings(encodings)[0] || false;
}
/**
* Return accepted charsets or best fit based on `charsets`.
*
* Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5`
* an array sorted by quality is returned:
*
* ['utf-8', 'utf-7', 'iso-8859-1']
*
* @param {String|Array} charset(s)...
* @return {String|Array}
* @api public
*/
Accepts.prototype.charset =
Accepts.prototype.charsets = function (charsets) {
if (!Array.isArray(charsets)) charsets = [].slice.call(arguments);
var n = this.negotiator;
if (!charsets.length) return n.charsets();
if (!this.headers['accept-charset']) return charsets[0];
return n.charsets(charsets)[0] || false;
}
/**
* Return accepted languages or best fit based on `langs`.
*
* Given `Accept-Language: en;q=0.8, es, pt`
* an array sorted by quality is returned:
*
* ['es', 'pt', 'en']
*
* @param {String|Array} lang(s)...
* @return {Array|String}
* @api public
*/
Accepts.prototype.lang =
Accepts.prototype.langs =
Accepts.prototype.language =
Accepts.prototype.languages = function (langs) {
if (!Array.isArray(langs)) langs = slice.call(arguments);
var n = this.negotiator;
if (!langs.length) return n.languages();
if (!this.headers['accept-language']) return langs[0];
return n.languages(langs)[0] || false;
}
/**
* Convert extnames to mime.
*
* @param {String} type
* @return {String}
* @api private
*/
function extToMime(type) {
if (~type.indexOf('/')) return type;
return mime.lookup(type);
}
Copyright (c) 2010 Benjamin Thomas, Robert Kieffer
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.
# mime
Comprehensive MIME type mapping API. Includes all 600+ types and 800+ extensions defined by the Apache project, plus additional types submitted by the node.js community.
## Install
Install with [npm](http://github.com/isaacs/npm):
npm install mime
## API - Queries
### mime.lookup(path)
Get the mime type associated with a file, if no mime type is found `application/octet-stream` is returned. Performs a case-insensitive lookup using the extension in `path` (the substring after the last '/' or '.'). E.g.
var mime = require('mime');
mime.lookup('/path/to/file.txt'); // => 'text/plain'
mime.lookup('file.txt'); // => 'text/plain'
mime.lookup('.TXT'); // => 'text/plain'
mime.lookup('htm'); // => 'text/html'
### mime.default_type
Sets the mime type returned when `mime.lookup` fails to find the extension searched for. (Default is `application/octet-stream`.)
### mime.extension(type)
Get the default extension for `type`
mime.extension('text/html'); // => 'html'
mime.extension('application/octet-stream'); // => 'bin'
### mime.charsets.lookup()
Map mime-type to charset
mime.charsets.lookup('text/plain'); // => 'UTF-8'
(The logic for charset lookups is pretty rudimentary. Feel free to suggest improvements.)
## API - Defining Custom Types
The following APIs allow you to add your own type mappings within your project. If you feel a type should be included as part of node-mime, see [requesting new types](https://github.com/broofa/node-mime/wiki/Requesting-New-Types).
### mime.define()
Add custom mime/extension mappings
mime.define({
'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'],
'application/x-my-type': ['x-mt', 'x-mtt'],
// etc ...
});
mime.lookup('x-sft'); // => 'text/x-some-format'
The first entry in the extensions array is returned by `mime.extension()`. E.g.
mime.extension('text/x-some-format'); // => 'x-sf'
### mime.load(filepath)
Load mappings from an Apache ".types" format file
mime.load('./my_project.types');
The .types file format is simple - See the `types` dir for examples.
var path = require('path');
var fs = require('fs');
function Mime() {
// Map of extension -> mime type
this.types = Object.create(null);
// Map of mime type -> extension
this.extensions = Object.create(null);
}
/**
* Define mimetype -> extension mappings. Each key is a mime-type that maps
* to an array of extensions associated with the type. The first extension is
* used as the default extension for the type.
*
* e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
*
* @param map (Object) type definitions
*/
Mime.prototype.define = function (map) {
for (var type in map) {
var exts = map[type];
for (var i = 0; i < exts.length; i++) {
if (process.env.DEBUG_MIME && this.types[exts]) {
console.warn(this._loading.replace(/.*\//, ''), 'changes "' + exts[i] + '" extension type from ' +
this.types[exts] + ' to ' + type);
}
this.types[exts[i]] = type;
}
// Default extension is the first one we encounter
if (!this.extensions[type]) {
this.extensions[type] = exts[0];
}
}
};
/**
* Load an Apache2-style ".types" file
*
* This may be called multiple times (it's expected). Where files declare
* overlapping types/extensions, the last file wins.
*
* @param file (String) path of file to load.
*/
Mime.prototype.load = function(file) {
this._loading = file;
// Read file and split into lines
var map = {},
content = fs.readFileSync(file, 'ascii'),
lines = content.split(/[\r\n]+/);
lines.forEach(function(line) {
// Clean up whitespace/comments, and split into fields
var fields = line.replace(/\s*#.*|^\s*|\s*$/g, '').split(/\s+/);
map[fields.shift()] = fields;
});
this.define(map);
this._loading = null;
};
/**
* Lookup a mime type based on extension
*/
Mime.prototype.lookup = function(path, fallback) {
var ext = path.replace(/.*[\.\/\\]/, '').toLowerCase();
return this.types[ext] || fallback || this.default_type;
};
/**
* Return file extension associated with a mime type
*/
Mime.prototype.extension = function(mimeType) {
var type = mimeType.match(/^\s*([^;\s]*)(?:;|\s|$)/)[1].toLowerCase();
return this.extensions[type];
};
// Default instance
var mime = new Mime();
// Load local copy of
// http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
mime.load(path.join(__dirname, 'types/mime.types'));
// Load additional types from node.js community
mime.load(path.join(__dirname, 'types/node.types'));
// Default type
mime.default_type = mime.lookup('bin');
//
// Additional API specific to the default instance
//
mime.Mime = Mime;
/**
* Lookup a charset based on mime type.
*/
mime.charsets = {
lookup: function(mimeType, fallback) {
// Assume text types are utf8
return (/^text\//).test(mimeType) ? 'UTF-8' : fallback;
}
};
module.exports = mime;
{
"author": {
"name": "Robert Kieffer",
"email": "robert@broofa.com",
"url": "http://github.com/broofa"
},
"contributors": [
{
"name": "Benjamin Thomas",
"email": "benjamin@benjaminthomas.org",
"url": "http://github.com/bentomas"
}
],
"dependencies": {},
"description": "A comprehensive library for mime-type mapping",
"devDependencies": {},
"keywords": [
"util",
"mime"
],
"main": "mime.js",
"name": "mime",
"repository": {
"url": "https://github.com/broofa/node-mime",
"type": "git"
},
"version": "1.2.11",
"readme": "# mime\n\nComprehensive MIME type mapping API. Includes all 600+ types and 800+ extensions defined by the Apache project, plus additional types submitted by the node.js community.\n\n## Install\n\nInstall with [npm](http://github.com/isaacs/npm):\n\n npm install mime\n\n## API - Queries\n\n### mime.lookup(path)\nGet the mime type associated with a file, if no mime type is found `application/octet-stream` is returned. Performs a case-insensitive lookup using the extension in `path` (the substring after the last '/' or '.'). E.g.\n\n var mime = require('mime');\n\n mime.lookup('/path/to/file.txt'); // => 'text/plain'\n mime.lookup('file.txt'); // => 'text/plain'\n mime.lookup('.TXT'); // => 'text/plain'\n mime.lookup('htm'); // => 'text/html'\n\n### mime.default_type\nSets the mime type returned when `mime.lookup` fails to find the extension searched for. (Default is `application/octet-stream`.)\n\n### mime.extension(type)\nGet the default extension for `type`\n\n mime.extension('text/html'); // => 'html'\n mime.extension('application/octet-stream'); // => 'bin'\n\n### mime.charsets.lookup()\n\nMap mime-type to charset\n\n mime.charsets.lookup('text/plain'); // => 'UTF-8'\n\n(The logic for charset lookups is pretty rudimentary. Feel free to suggest improvements.)\n\n## API - Defining Custom Types\n\nThe following APIs allow you to add your own type mappings within your project. If you feel a type should be included as part of node-mime, see [requesting new types](https://github.com/broofa/node-mime/wiki/Requesting-New-Types).\n\n### mime.define()\n\nAdd custom mime/extension mappings\n\n mime.define({\n 'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'],\n 'application/x-my-type': ['x-mt', 'x-mtt'],\n // etc ...\n });\n\n mime.lookup('x-sft'); // => 'text/x-some-format'\n\nThe first entry in the extensions array is returned by `mime.extension()`. E.g.\n\n mime.extension('text/x-some-format'); // => 'x-sf'\n\n### mime.load(filepath)\n\nLoad mappings from an Apache \".types\" format file\n\n mime.load('./my_project.types');\n\nThe .types file format is simple - See the `types` dir for examples.\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/broofa/node-mime/issues"
},
"_id": "mime@1.2.11",
"_from": "mime@~1.2.11"
}
/**
* Usage: node test.js
*/
var mime = require('./mime');
var assert = require('assert');
var path = require('path');
function eq(a, b) {
console.log('Test: ' + a + ' === ' + b);
assert.strictEqual.apply(null, arguments);
}
console.log(Object.keys(mime.extensions).length + ' types');
console.log(Object.keys(mime.types).length + ' extensions\n');
//
// Test mime lookups
//
eq('text/plain', mime.lookup('text.txt')); // normal file
eq('text/plain', mime.lookup('TEXT.TXT')); // uppercase
eq('text/plain', mime.lookup('dir/text.txt')); // dir + file
eq('text/plain', mime.lookup('.text.txt')); // hidden file
eq('text/plain', mime.lookup('.txt')); // nameless
eq('text/plain', mime.lookup('txt')); // extension-only
eq('text/plain', mime.lookup('/txt')); // extension-less ()
eq('text/plain', mime.lookup('\\txt')); // Windows, extension-less
eq('application/octet-stream', mime.lookup('text.nope')); // unrecognized
eq('fallback', mime.lookup('text.fallback', 'fallback')); // alternate default
//
// Test extensions
//
eq('txt', mime.extension(mime.types.text));
eq('html', mime.extension(mime.types.htm));
eq('bin', mime.extension('application/octet-stream'));
eq('bin', mime.extension('application/octet-stream '));
eq('html', mime.extension(' text/html; charset=UTF-8'));
eq('html', mime.extension('text/html; charset=UTF-8 '));
eq('html', mime.extension('text/html; charset=UTF-8'));
eq('html', mime.extension('text/html ; charset=UTF-8'));
eq('html', mime.extension('text/html;charset=UTF-8'));
eq('html', mime.extension('text/Html;charset=UTF-8'));
eq(undefined, mime.extension('unrecognized'));
//
// Test node.types lookups
//
eq('application/font-woff', mime.lookup('file.woff'));
eq('application/octet-stream', mime.lookup('file.buffer'));
eq('audio/mp4', mime.lookup('file.m4a'));
eq('font/opentype', mime.lookup('file.otf'));
//
// Test charsets
//
eq('UTF-8', mime.charsets.lookup('text/plain'));
eq(undefined, mime.charsets.lookup(mime.types.js));
eq('fallback', mime.charsets.lookup('application/octet-stream', 'fallback'));
//
// Test for overlaps between mime.types and node.types
//
var apacheTypes = new mime.Mime(), nodeTypes = new mime.Mime();
apacheTypes.load(path.join(__dirname, 'types/mime.types'));
nodeTypes.load(path.join(__dirname, 'types/node.types'));
var keys = [].concat(Object.keys(apacheTypes.types))
.concat(Object.keys(nodeTypes.types));
keys.sort();
for (var i = 1; i < keys.length; i++) {
if (keys[i] == keys[i-1]) {
console.warn('Warning: ' +
'node.types defines ' + keys[i] + '->' + nodeTypes.types[keys[i]] +
', mime.types defines ' + keys[i] + '->' + apacheTypes.types[keys[i]]);
}
}
console.log('\nOK');
# What: WebVTT
# Why: To allow formats intended for marking up external text track resources.
# http://dev.w3.org/html5/webvtt/
# Added by: niftylettuce
text/vtt vtt
# What: Google Chrome Extension
# Why: To allow apps to (work) be served with the right content type header.
# http://codereview.chromium.org/2830017
# Added by: niftylettuce
application/x-chrome-extension crx
# What: HTC support
# Why: To properly render .htc files such as CSS3PIE
# Added by: niftylettuce
text/x-component htc
# What: HTML5 application cache manifes ('.manifest' extension)
# Why: De-facto standard. Required by Mozilla browser when serving HTML5 apps
# per https://developer.mozilla.org/en/offline_resources_in_firefox
# Added by: louisremi
text/cache-manifest manifest
# What: node binary buffer format
# Why: semi-standard extension w/in the node community
# Added by: tootallnate
application/octet-stream buffer
# What: The "protected" MP-4 formats used by iTunes.
# Why: Required for streaming music to browsers (?)
# Added by: broofa
application/mp4 m4p
audio/mp4 m4a
# What: Video format, Part of RFC1890
# Why: See https://github.com/bentomas/node-mime/pull/6
# Added by: mjrusso
video/MP2T ts
# What: EventSource mime type
# Why: mime type of Server-Sent Events stream
# http://www.w3.org/TR/eventsource/#text-event-stream
# Added by: francois2metz
text/event-stream event-stream
# What: Mozilla App manifest mime type
# Why: https://developer.mozilla.org/en/Apps/Manifest#Serving_manifests
# Added by: ednapiranha
application/x-web-app-manifest+json webapp
# What: Lua file types
# Why: Googling around shows de-facto consensus on these
# Added by: creationix (Issue #45)
text/x-lua lua
application/x-lua-bytecode luac
# What: Markdown files, as per http://daringfireball.net/projects/markdown/syntax
# Why: http://stackoverflow.com/questions/10701983/what-is-the-mime-type-for-markdown
# Added by: avoidwork
text/x-markdown markdown md mkd
# What: ini files
# Why: because they're just text files
# Added by: Matthew Kastor
text/plain ini
# What: DASH Adaptive Streaming manifest
# Why: https://developer.mozilla.org/en-US/docs/DASH_Adaptive_Streaming_for_HTML_5_Video
# Added by: eelcocramer
application/dash+xml mdp
# What: OpenType font files - http://www.microsoft.com/typography/otspec/
# Why: Browsers usually ignore the font MIME types and sniff the content,
# but Chrome, shows a warning if OpenType fonts aren't served with
# the `font/opentype` MIME type: http://i.imgur.com/8c5RN8M.png.
# Added by: alrra
font/opentype otf
Original "Negotiator" program Copyright Federico Romero
Port to JavaScript Copyright Isaac Z. Schlueter
All rights reserved.
MIT License
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.
module.exports = preferredCharsets;
preferredCharsets.preferredCharsets = preferredCharsets;
function parseAcceptCharset(accept) {
return accept.split(',').map(function(e) {
return parseCharset(e.trim());
}).filter(function(e) {
return e;
});
}
function parseCharset(s) {
var match = s.match(/^\s*(\S+?)\s*(?:;(.*))?$/);
if (!match) return null;
var charset = match[1];
var q = 1;
if (match[2]) {
var params = match[2].split(';')
for (var i = 0; i < params.length; i ++) {
var p = params[i].trim().split('=');
if (p[0] === 'q') {
q = parseFloat(p[1]);
break;
}
}
}
return {
charset: charset,
q: q
};
}
function getCharsetPriority(charset, accepted) {
return (accepted.map(function(a) {
return specify(charset, a);
}).filter(Boolean).sort(function (a, b) {
if(a.s == b.s) {
return a.q > b.q ? -1 : 1;
} else {
return a.s > b.s ? -1 : 1;
}
})[0] || {s: 0, q:0});
}
function specify(charset, spec) {
var s = 0;
if(spec.charset === charset){
s |= 1;
} else if (spec.charset !== '*' ) {
return null
}
return {
s: s,
q: spec.q,
}
}
function preferredCharsets(accept, provided) {
// RFC 2616 sec 14.2: no header = *
accept = parseAcceptCharset(accept === undefined ? '*' : accept || '');
if (provided) {
return provided.map(function(type) {
return [type, getCharsetPriority(type, accept)];
}).filter(function(pair) {
return pair[1].q > 0;
}).sort(function(a, b) {
var pa = a[1];
var pb = b[1];
if(pa.q == pb.q) {
return pa.s < pb.s ? 1 : -1;
} else {
return pa.q < pb.q ? 1 : -1;
}
}).map(function(pair) {
return pair[0];
});
} else {
return accept.sort(function (a, b) {
// revsort
return a.q < b.q ? 1 : -1;
}).filter(function(type) {
return type.q > 0;
}).map(function(type) {
return type.charset;
});
}
}
module.exports = preferredEncodings;
preferredEncodings.preferredEncodings = preferredEncodings;
function parseAcceptEncoding(accept) {
var acceptableEncodings;
if (accept) {
acceptableEncodings = accept.split(',').map(function(e) {
return parseEncoding(e.trim());
});
} else {
acceptableEncodings = [];
}
if (!acceptableEncodings.some(function(e) {
return e && specify('identity', e);
})) {
/*
* If identity doesn't explicitly appear in the accept-encoding header,
* it's added to the list of acceptable encoding with the lowest q
*
*/
var lowestQ = 1;
for(var i = 0; i < acceptableEncodings.length; i++){
var e = acceptableEncodings[i];
if(e && e.q < lowestQ){
lowestQ = e.q;
}
}
acceptableEncodings.push({
encoding: 'identity',
q: lowestQ / 2,
});
}
return acceptableEncodings.filter(function(e) {
return e;
});
}
function parseEncoding(s) {
var match = s.match(/^\s*(\S+?)\s*(?:;(.*))?$/);
if (!match) return null;
var encoding = match[1];
var q = 1;
if (match[2]) {
var params = match[2].split(';');
for (var i = 0; i < params.length; i ++) {
var p = params[i].trim().split('=');
if (p[0] === 'q') {
q = parseFloat(p[1]);
break;
}
}
}
return {
encoding: encoding,
q: q
};
}
function getEncodingPriority(encoding, accepted) {
return (accepted.map(function(a) {
return specify(encoding, a);
}).filter(Boolean).sort(function (a, b) {
if(a.s == b.s) {
return a.q > b.q ? -1 : 1;
} else {
return a.s > b.s ? -1 : 1;
}
})[0] || {s: 0, q: 0});
}
function specify(encoding, spec) {
var s = 0;
if(spec.encoding === encoding){
s |= 1;
} else if (spec.encoding !== '*' ) {
return null
}
return {
s: s,
q: spec.q,
}
};
function preferredEncodings(accept, provided) {
accept = parseAcceptEncoding(accept || '');
if (provided) {
return provided.map(function(type) {
return [type, getEncodingPriority(type, accept)];
}).filter(function(pair) {
return pair[1].q > 0;
}).sort(function(a, b) {
var pa = a[1];
var pb = b[1];
if(pa.q == pb.q) {
return pa.s < pb.s ? 1 : -1;
} else {
return pa.q < pb.q ? 1 : -1;
}
}).map(function(pair) {
return pair[0];
});
} else {
return accept.sort(function (a, b) {
// revsort
return a.q < b.q ? 1 : -1;
}).filter(function(type){
return type.q > 0;
}).map(function(type) {
return type.encoding;
});
}
}
module.exports = preferredLanguages;
preferredLanguages.preferredLanguages = preferredLanguages;
function parseAcceptLanguage(accept) {
return accept.split(',').map(function(e) {
return parseLanguage(e.trim());
}).filter(function(e) {
return e;
});
}
function parseLanguage(s) {
var match = s.match(/^\s*(\S+?)(?:-(\S+?))?\s*(?:;(.*))?$/);
if (!match) return null;
var prefix = match[1],
suffix = match[2],
full = prefix;
if (suffix) full += "-" + suffix;
var q = 1;
if (match[3]) {
var params = match[3].split(';')
for (var i = 0; i < params.length; i ++) {
var p = params[i].split('=');
if (p[0] === 'q') q = parseFloat(p[1]);
}
}
return {
prefix: prefix,
suffix: suffix,
q: q,
full: full
};
}
function getLanguagePriority(language, accepted) {
return (accepted.map(function(a){
return specify(language, a);
}).filter(Boolean).sort(function (a, b) {
if(a.s == b.s) {
return a.q > b.q ? -1 : 1;
} else {
return a.s > b.s ? -1 : 1;
}
})[0] || {s: 0, q: 0});
}
function specify(language, spec) {
var p = parseLanguage(language)
var s = 0;
if(spec.full === p.full){
s |= 4;
} else if (spec.prefix === p.full) {
s |= 2;
} else if (spec.full === p.prefix) {
s |= 1;
} else if (spec.full !== '*' ) {
return null
}
return {
s: s,
q: spec.q,
}
};
function preferredLanguages(accept, provided) {
// RFC 2616 sec 14.4: no header = *
accept = parseAcceptLanguage(accept === undefined ? '*' : accept || '');
if (provided) {
var ret = provided.map(function(type) {
return [type, getLanguagePriority(type, accept)];
}).filter(function(pair) {
return pair[1].q > 0;
}).sort(function(a, b) {
var pa = a[1];
var pb = b[1];
if(pa.q == pb.q) {
return pa.s < pb.s ? 1 : -1;
} else {
return pa.q < pb.q ? 1 : -1;
}
}).map(function(pair) {
return pair[0];
});
return ret;
} else {
return accept.sort(function (a, b) {
// revsort
return a.q < b.q ? 1 : -1;
}).filter(function(type) {
return type.q > 0;
}).map(function(type) {
return type.full;
});
}
}
module.exports = preferredMediaTypes;
preferredMediaTypes.preferredMediaTypes = preferredMediaTypes;
function parseAccept(accept) {
return accept.split(',').map(function(e) {
return parseMediaType(e.trim());
}).filter(function(e) {
return e;
});
};
function parseMediaType(s) {
var match = s.match(/\s*(\S+?)\/([^;\s]+)\s*(?:;(.*))?/);
if (!match) return null;
var type = match[1],
subtype = match[2],
full = "" + type + "/" + subtype,
params = {},
q = 1;
if (match[3]) {
params = match[3].split(';').map(function(s) {
return s.trim().split('=');
}).reduce(function (set, p) {
set[p[0]] = p[1];
return set
}, params);
if (params.q != null) {
q = parseFloat(params.q);
delete params.q;
}
}
return {
type: type,
subtype: subtype,
params: params,
q: q,
full: full
};
}
function getMediaTypePriority(type, accepted) {
return (accepted.map(function(a) {
return specify(type, a);
}).filter(Boolean).sort(function (a, b) {
if(a.s == b.s) {
return a.q > b.q ? -1 : 1;
} else {
return a.s > b.s ? -1 : 1;
}
})[0] || {s: 0, q: 0});
}
function specify(type, spec) {
var p = parseMediaType(type);
var s = 0;
if(spec.type == p.type) {
s |= 4
} else if(spec.type != '*') {
return null;
}
if(spec.subtype == p.subtype) {
s |= 2
} else if(spec.subtype != '*') {
return null;
}
var keys = Object.keys(spec.params);
if (keys.length > 0) {
if (keys.every(function (k) {
return spec.params[k] == '*' || spec.params[k] == p.params[k];
})) {
s |= 1
} else {
return null
}
}
return {
q: spec.q,
s: s,
}
}
function preferredMediaTypes(accept, provided) {
// RFC 2616 sec 14.2: no header = */*
accept = parseAccept(accept === undefined ? '*/*' : accept || '');
if (provided) {
return provided.map(function(type) {
return [type, getMediaTypePriority(type, accept)];
}).filter(function(pair) {
return pair[1].q > 0;
}).sort(function(a, b) {
var pa = a[1];
var pb = b[1];
if(pa.q == pb.q) {
return pa.s < pb.s ? 1 : -1;
} else {
return pa.q < pb.q ? 1 : -1;
}
}).map(function(pair) {
return pair[0];
});
} else {
return accept.sort(function (a, b) {
// revsort
return a.q < b.q ? 1 : -1;
}).filter(function(type) {
return type.q > 0;
}).map(function(type) {
return type.full;
});
}
}
module.exports = Negotiator;
Negotiator.Negotiator = Negotiator;
function Negotiator(request) {
if (!(this instanceof Negotiator)) return new Negotiator(request);
this.request = request;
}
var set = { charset: 'accept-charset',
encoding: 'accept-encoding',
language: 'accept-language',
mediaType: 'accept' };
function capitalize(string){
return string.charAt(0).toUpperCase() + string.slice(1);
}
Object.keys(set).forEach(function (k) {
var header = set[k],
method = require('./'+k+'.js'),
singular = k,
plural = k + 's';
Negotiator.prototype[plural] = function (available) {
return method(this.request.headers[header], available);
};
Negotiator.prototype[singular] = function(available) {
var set = this[plural](available);
if (set) return set[0];
};
// Keep preferred* methods for legacy compatibility
Negotiator.prototype['preferred'+capitalize(plural)] = Negotiator.prototype[plural];
Negotiator.prototype['preferred'+capitalize(singular)] = Negotiator.prototype[singular];
})
{
"name": "negotiator",
"description": "HTTP content negotiation",
"version": "0.4.6",
"author": {
"name": "Federico Romero",
"email": "federico.romero@outboxlabs.com"
},
"contributors": [
{
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
"url": "http://blog.izs.me/"
}
],
"repository": {
"type": "git",
"url": "git://github.com/federomero/negotiator.git"
},
"keywords": [
"http",
"content negotiation",
"accept",
"accept-language",
"accept-encoding",
"accept-charset"
],
"engine": "node >= 0.6",
"license": "MIT",
"devDependencies": {
"nodeunit": "0.8.x"
},
"scripts": {
"test": "nodeunit test"
},
"optionalDependencies": {},
"engines": {
"node": "*"
},
"main": "lib/negotiator.js",
"readme": "# Negotiator [![Build Status](https://travis-ci.org/federomero/negotiator.png)](https://travis-ci.org/federomero/negotiator)\n\nAn HTTP content negotiator for node.js written in javascript.\n\n# Accept Negotiation\n\n Negotiator = require('negotiator')\n\n availableMediaTypes = ['text/html', 'text/plain', 'application/json']\n\n // The negotiator constructor receives a request object\n negotiator = new Negotiator(request)\n\n // Let's say Accept header is 'text/html, application/*;q=0.2, image/jpeg;q=0.8'\n\n negotiator.mediaTypes()\n // -> ['text/html', 'image/jpeg', 'application/*']\n\n negotiator.mediaTypes(availableMediaTypes)\n // -> ['text/html', 'application/json']\n\n negotiator.mediaType(availableMediaTypes)\n // -> 'text/html'\n\nYou can check a working example at `examples/accept.js`.\n\n## Methods\n\n`mediaTypes(availableMediaTypes)`:\n\nReturns an array of preferred media types ordered by priority from a list of available media types.\n\n`mediaType(availableMediaType)`:\n\nReturns the top preferred media type from a list of available media types.\n\n# Accept-Language Negotiation\n\n Negotiator = require('negotiator')\n\n negotiator = new Negotiator(request)\n\n availableLanguages = 'en', 'es', 'fr'\n\n // Let's say Accept-Language header is 'en;q=0.8, es, pt'\n\n negotiator.languages()\n // -> ['es', 'pt', 'en']\n\n negotiator.languages(availableLanguages)\n // -> ['es', 'en']\n\n language = negotiator.language(availableLanguages)\n // -> 'es'\n\nYou can check a working example at `examples/language.js`.\n\n## Methods\n\n`languages(availableLanguages)`:\n\nReturns an array of preferred languages ordered by priority from a list of available languages.\n\n`language(availableLanguages)`:\n\nReturns the top preferred language from a list of available languages.\n\n# Accept-Charset Negotiation\n\n Negotiator = require('negotiator')\n\n availableCharsets = ['utf-8', 'iso-8859-1', 'iso-8859-5']\n\n negotiator = new Negotiator(request)\n\n // Let's say Accept-Charset header is 'utf-8, iso-8859-1;q=0.8, utf-7;q=0.2'\n\n negotiator.charsets()\n // -> ['utf-8', 'iso-8859-1', 'utf-7']\n\n negotiator.charsets(availableCharsets)\n // -> ['utf-8', 'iso-8859-1']\n\n negotiator.charset(availableCharsets)\n // -> 'utf-8'\n\nYou can check a working example at `examples/charset.js`.\n\n## Methods\n\n`charsets(availableCharsets)`:\n\nReturns an array of preferred charsets ordered by priority from a list of available charsets.\n\n`charset(availableCharsets)`:\n\nReturns the top preferred charset from a list of available charsets.\n\n# Accept-Encoding Negotiation\n\n Negotiator = require('negotiator').Negotiator\n\n availableEncodings = ['identity', 'gzip']\n\n negotiator = new Negotiator(request)\n\n // Let's say Accept-Encoding header is 'gzip, compress;q=0.2, identity;q=0.5'\n\n negotiator.encodings()\n // -> ['gzip', 'identity', 'compress']\n\n negotiator.encodings(availableEncodings)\n // -> ['gzip', 'identity']\n\n negotiator.encoding(availableEncodings)\n // -> 'gzip'\n\nYou can check a working example at `examples/encoding.js`.\n\n## Methods\n\n`encodings(availableEncodings)`:\n\nReturns an array of preferred encodings ordered by priority from a list of available encodings.\n\n`encoding(availableEncodings)`:\n\nReturns the top preferred encoding from a list of available encodings.\n\n# License\n\nMIT\n",
"readmeFilename": "readme.md",
"bugs": {
"url": "https://github.com/federomero/negotiator/issues"
},
"dependencies": {},
"_id": "negotiator@0.4.6",
"_from": "negotiator@0.4.6"
}
# Negotiator [![Build Status](https://travis-ci.org/federomero/negotiator.png)](https://travis-ci.org/federomero/negotiator)
An HTTP content negotiator for node.js written in javascript.
# Accept Negotiation
Negotiator = require('negotiator')
availableMediaTypes = ['text/html', 'text/plain', 'application/json']
// The negotiator constructor receives a request object
negotiator = new Negotiator(request)
// Let's say Accept header is 'text/html, application/*;q=0.2, image/jpeg;q=0.8'
negotiator.mediaTypes()
// -> ['text/html', 'image/jpeg', 'application/*']
negotiator.mediaTypes(availableMediaTypes)
// -> ['text/html', 'application/json']
negotiator.mediaType(availableMediaTypes)
// -> 'text/html'
You can check a working example at `examples/accept.js`.
## Methods
`mediaTypes(availableMediaTypes)`:
Returns an array of preferred media types ordered by priority from a list of available media types.
`mediaType(availableMediaType)`:
Returns the top preferred media type from a list of available media types.
# Accept-Language Negotiation
Negotiator = require('negotiator')
negotiator = new Negotiator(request)
availableLanguages = 'en', 'es', 'fr'
// Let's say Accept-Language header is 'en;q=0.8, es, pt'
negotiator.languages()
// -> ['es', 'pt', 'en']
negotiator.languages(availableLanguages)
// -> ['es', 'en']
language = negotiator.language(availableLanguages)
// -> 'es'
You can check a working example at `examples/language.js`.
## Methods
`languages(availableLanguages)`:
Returns an array of preferred languages ordered by priority from a list of available languages.
`language(availableLanguages)`:
Returns the top preferred language from a list of available languages.
# Accept-Charset Negotiation
Negotiator = require('negotiator')
availableCharsets = ['utf-8', 'iso-8859-1', 'iso-8859-5']
negotiator = new Negotiator(request)
// Let's say Accept-Charset header is 'utf-8, iso-8859-1;q=0.8, utf-7;q=0.2'
negotiator.charsets()
// -> ['utf-8', 'iso-8859-1', 'utf-7']
negotiator.charsets(availableCharsets)
// -> ['utf-8', 'iso-8859-1']
negotiator.charset(availableCharsets)
// -> 'utf-8'
You can check a working example at `examples/charset.js`.
## Methods
`charsets(availableCharsets)`:
Returns an array of preferred charsets ordered by priority from a list of available charsets.
`charset(availableCharsets)`:
Returns the top preferred charset from a list of available charsets.
# Accept-Encoding Negotiation
Negotiator = require('negotiator').Negotiator
availableEncodings = ['identity', 'gzip']
negotiator = new Negotiator(request)
// Let's say Accept-Encoding header is 'gzip, compress;q=0.2, identity;q=0.5'
negotiator.encodings()
// -> ['gzip', 'identity', 'compress']
negotiator.encodings(availableEncodings)
// -> ['gzip', 'identity']
negotiator.encoding(availableEncodings)
// -> 'gzip'
You can check a working example at `examples/encoding.js`.
## Methods
`encodings(availableEncodings)`:
Returns an array of preferred encodings ordered by priority from a list of available encodings.
`encoding(availableEncodings)`:
Returns the top preferred encoding from a list of available encodings.
# License
MIT
{
"name": "accepts",
"description": "Higher-level content negotiation",
"version": "1.0.3",
"author": {
"name": "Jonathan Ong",
"email": "me@jongleberry.com",
"url": "http://jongleberry.com"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/expressjs/accepts"
},
"dependencies": {
"mime": "~1.2.11",
"negotiator": "0.4.6"
},
"devDependencies": {
"istanbul": "0.2.10",
"mocha": "*",
"should": "*"
},
"engines": {
"node": ">= 0.8.0"
},
"scripts": {
"test": "mocha --require should --reporter dot test/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require should --reporter dot test/",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require should --reporter spec test/"
},
"readme": "# Accepts\n\n[![NPM version](https://badge.fury.io/js/accepts.svg)](http://badge.fury.io/js/accepts)\n[![Build Status](https://travis-ci.org/expressjs/accepts.svg?branch=master)](https://travis-ci.org/expressjs/accepts)\n[![Coverage Status](https://img.shields.io/coveralls/expressjs/accepts.svg?branch=master)](https://coveralls.io/r/expressjs/accepts)\n\nHigher level content negotation based on [negotiator](https://github.com/federomero/negotiator). Extracted from [koa](https://github.com/koajs/koa) for general use.\n\nIn addition to negotatior, it allows:\n\n- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])` as well as `('text/html', 'application/json')`.\n- Allows type shorthands such as `json`.\n- Returns `false` when no types match\n- Treats non-existent headers as `*`\n\n## API\n\n### var accept = new Accepts(req)\n\n```js\nvar accepts = require('accepts')\n\nhttp.createServer(function (req, res) {\n var accept = accepts(req)\n})\n```\n\n### accept\\[property\\]\\(\\)\n\nReturns all the explicitly accepted content property as an array in descending priority.\n\n- `accept.types()`\n- `accept.encodings()`\n- `accept.charsets()`\n- `accept.languages()`\n\nThey are also aliased in singular form such as `accept.type()`. `accept.languages()` is also aliased as `accept.langs()`, etc.\n\nNote: you should almost never do this in a real app as it defeats the purpose of content negotiation.\n\nExample:\n\n```js\n// in Google Chrome\nvar encodings = accept.encodings() // -> ['sdch', 'gzip', 'deflate']\n```\n\nSince you probably don't support `sdch`, you should just supply the encodings you support:\n\n```js\nvar encoding = accept.encodings('gzip', 'deflate') // -> 'gzip', probably\n```\n\n### accept\\[property\\]\\(values, ...\\)\n\nYou can either have `values` be an array or have an argument list of values.\n\nIf the client does not accept any `values`, `false` will be returned.\nIf the client accepts any `values`, the preferred `value` will be return.\n\nFor `accept.types()`, shorthand mime types are allowed.\n\nExample:\n\n```js\n// req.headers.accept = 'application/json'\n\naccept.types('json') // -> 'json'\naccept.types('html', 'json') // -> 'json'\naccept.types('html') // -> false\n\n// req.headers.accept = ''\n// which is equivalent to `*`\n\naccept.types() // -> [], no explicit types\naccept.types('text/html', 'text/json') // -> 'text/html', since it was first\n```\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2013 Jonathan Ong me@jongleberry.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/expressjs/accepts/issues"
},
"_id": "accepts@1.0.3",
"_from": "accepts@1.0.3"
}
build: components index.js
@component build
components:
@Component install
clean:
rm -fr build components template.js
.PHONY: clean
# escape-html
Escape HTML entities
## Example
```js
var escape = require('escape-html');
escape(str);
```
## License
MIT
\ No newline at end of file
{
"name": "escape-html",
"description": "Escape HTML entities",
"version": "1.0.1",
"keywords": ["escape", "html", "utility"],
"dependencies": {},
"scripts": [
"index.js"
]
}
/**
* Escape special characters in the given string of html.
*
* @param {String} html
* @return {String}
* @api private
*/
module.exports = function(html) {
return String(html)
.replace(/&/g, '&amp;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;');
}
{
"name": "escape-html",
"description": "Escape HTML entities",
"version": "1.0.1",
"keywords": [
"escape",
"html",
"utility"
],
"dependencies": {},
"main": "index.js",
"component": {
"scripts": {
"escape-html/index.js": "index.js"
}
},
"repository": {
"type": "git",
"url": "https://github.com/component/escape-html.git"
},
"readme": "\n# escape-html\n\n Escape HTML entities\n\n## Example\n\n```js\nvar escape = require('escape-html');\nescape(str);\n```\n\n## License\n\n MIT",
"readmeFilename": "Readme.md",
"bugs": {
"url": "https://github.com/component/escape-html/issues"
},
"_id": "escape-html@1.0.1",
"_from": "escape-html@1.0.1"
}
{
"name": "errorhandler",
"description": "connect's default error handler page",
"version": "1.0.2",
"version": "1.1.0",
"author": {
"name": "Jonathan Ong",
"email": "me@jongleberry.com",
......@@ -12,10 +12,14 @@
"type": "git",
"url": "git://github.com/expressjs/errorhandler"
},
"dependencies": {
"accepts": "1.0.3",
"escape-html": "1.0.1"
},
"devDependencies": {
"connect": "3",
"istanbul": "0.2.10",
"mocha": ">= 1.17.0 < 2",
"mocha": "~1.20.1",
"should": "~4.0.1",
"supertest": "~0.13.0"
},
......@@ -32,10 +36,10 @@
"bugs": {
"url": "https://github.com/expressjs/errorhandler/issues"
},
"_id": "errorhandler@1.0.2",
"_id": "errorhandler@1.1.0",
"dist": {
"shasum": "18b3d7cf7f8cc6d34b758dc99fb79afa9697dab3"
"shasum": "7bb1df71337b0c350f065cc47733e4aa1014932c"
},
"_from": "errorhandler @*",
"_resolved": "https://registry.npmjs.org/errorhandler/-/errorhandler-1.0.2.tgz"
"_resolved": "https://registry.npmjs.org/errorhandler/-/errorhandler-1.1.0.tgz"
}
......@@ -31,6 +31,5 @@
"url": "https://github.com/broofa/node-mime/issues"
},
"_id": "mime@1.2.11",
"_from": "mime@~1.2.11",
"scripts": {}
"_from": "mime@~1.2.11"
}
......@@ -35,5 +35,9 @@
"url": "https://github.com/brianloveswords/buffer-crc32/issues"
},
"_id": "buffer-crc32@0.2.1",
"_from": "buffer-crc32@0.2.1"
"dist": {
"shasum": "f69b85da4d6e160c3d450a41ae7cddb5cbec4c95"
},
"_from": "buffer-crc32@0.2.1",
"_resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.1.tgz"
}
......@@ -21,5 +21,9 @@
"readme": "# Merge Descriptors [![Build Status](https://travis-ci.org/component/merge-descriptors.png)](https://travis-ci.org/component/merge-descriptors)\n\nMerge objects using descriptors.\n\n```js\nvar thing = {\n get name() {\n return 'jon'\n }\n}\n\nvar animal = {\n\n}\n\nmerge(animal, thing)\n\nanimal.name === 'jon'\n```\n\n## API\n\n### merge(destination, source)\n\nOverwrites `destination`'s descriptors with `source`'s.\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2013 Jonathan Ong me@jongleberry.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.",
"readmeFilename": "README.md",
"_id": "merge-descriptors@0.0.2",
"_from": "merge-descriptors@0.0.2"
"dist": {
"shasum": "64fe67a0481be3b6e66d4e03171af8da8e01d444"
},
"_from": "merge-descriptors@0.0.2",
"_resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-0.0.2.tgz"
}
......@@ -28,5 +28,9 @@
"url": "https://github.com/component/path-to-regexp/issues"
},
"_id": "path-to-regexp@0.1.2",
"_from": "path-to-regexp@0.1.2"
"dist": {
"shasum": "0baded381925a3a192624b76d23842a90948c281"
},
"_from": "path-to-regexp@0.1.2",
"_resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.2.tgz"
}
......@@ -43,5 +43,6 @@
"url": "https://github.com/visionmedia/debug/issues"
},
"_id": "debug@1.0.2",
"_from": "debug@1.0.2"
"_from": "debug@1.0.2",
"scripts": {}
}
......@@ -29,5 +29,6 @@
"url": "https://github.com/visionmedia/node-fresh/issues"
},
"_id": "fresh@0.2.2",
"_from": "fresh@0.2.2"
"_from": "fresh@0.2.2",
"scripts": {}
}
......@@ -29,5 +29,6 @@
"url": "https://github.com/visionmedia/node-range-parser/issues"
},
"_id": "range-parser@1.0.0",
"_from": "range-parser@~1.0.0"
"_from": "range-parser@~1.0.0",
"scripts": {}
}
......@@ -30,5 +30,9 @@
"url": "https://github.com/mranney/node_redis/issues"
},
"_id": "redis@0.7.3",
"_from": "redis@0.7.3"
"dist": {
"shasum": "00da64f7a42de77cca52e7e41772766a45523b9e"
},
"_from": "redis@0.7.3",
"_resolved": "https://registry.npmjs.org/redis/-/redis-0.7.3.tgz"
}
......@@ -63,5 +63,9 @@
"url": "https://github.com/LearnBoost/socket.io-client/issues"
},
"_id": "socket.io-client@0.9.16",
"_from": "socket.io-client@0.9.16"
"dist": {
"shasum": "b6bf3ef683b72ff4ebdb6620485173ccb794e714"
},
"_from": "socket.io-client@0.9.16",
"_resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-0.9.16.tgz"
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment