Update Node http-server to 0.10.0

This commit is contained in:
Joshua Granick
2017-06-05 15:10:10 -07:00
parent dab605d892
commit 1683c0db93
243 changed files with 8993 additions and 7868 deletions

View File

@@ -0,0 +1,2 @@
node_modules
coverage

View File

@@ -0,0 +1,19 @@
sudo: false
language: node_js
node_js:
- "4"
- "iojs"
- "0.12"
- "0.10"
script:
- "npm run test-travis"
after_script:
- "npm install coveralls@2 && cat coverage/lcov.info | coveralls"
matrix:
fast_finish: true
notifications:
irc:
channels:
- "irc.freenode.org#unshift"
on_success: change
on_failure: change

View File

@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2015 Unshift.io, Arnout Kazemier, the Contributors.
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.

View File

@@ -0,0 +1,38 @@
'use strict';
/**
* Check if we're required to add a port number.
*
* @see https://url.spec.whatwg.org/#default-port
* @param {Number|String} port Port number we need to check
* @param {String} protocol Protocol we need to check against.
* @returns {Boolean} Is it a default port for the given protocol
* @api private
*/
module.exports = function required(port, protocol) {
protocol = protocol.split(':')[0];
port = +port;
if (!port) return false;
switch (protocol) {
case 'http':
case 'ws':
return port !== 80;
case 'https':
case 'wss':
return port !== 443;
case 'ftp':
return port !== 21;
case 'gopher':
return port !== 70;
case 'file':
return false;
}
return port !== 0;
};

View File

@@ -0,0 +1,102 @@
{
"_args": [
[
"requires-port@1.x.x",
"/home/joshua/Development/Haxe/test/node_modules/http-proxy"
]
],
"_from": "requires-port@>=1.0.0 <2.0.0",
"_id": "requires-port@1.0.0",
"_inCache": true,
"_installable": true,
"_location": "/requires-port",
"_nodeVersion": "0.12.3",
"_npmUser": {
"email": "npm@3rd-Eden.com",
"name": "3rdeden"
},
"_npmVersion": "2.14.3",
"_phantomChildren": {},
"_requested": {
"name": "requires-port",
"raw": "requires-port@1.x.x",
"rawSpec": "1.x.x",
"scope": null,
"spec": ">=1.0.0 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/http-proxy"
],
"_resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
"_shasum": "925d2601d39ac485e091cf0da5c6e694dc3dcaff",
"_shrinkwrap": null,
"_spec": "requires-port@1.x.x",
"_where": "/home/joshua/Development/Haxe/test/node_modules/http-proxy",
"author": {
"name": "Arnout Kazemier"
},
"bugs": {
"url": "https://github.com/unshiftio/requires-port/issues"
},
"dependencies": {},
"description": "Check if a protocol requires a certain port number to be added to an URL.",
"devDependencies": {
"assume": "1.3.x",
"istanbul": "0.4.x",
"mocha": "2.3.x",
"pre-commit": "1.1.x"
},
"directories": {},
"dist": {
"shasum": "925d2601d39ac485e091cf0da5c6e694dc3dcaff",
"tarball": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz"
},
"gitHead": "3a552b935dd2ddba8f2ddf9096932f0f2024edfd",
"homepage": "https://github.com/unshiftio/requires-port",
"keywords": [
"cows",
"file",
"ftp",
"gopher",
"http",
"https",
"parsing",
"port",
"portnumber",
"require",
"requires",
"requried",
"url",
"validation",
"ws",
"wss"
],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"name": "v1",
"email": "info@3rd-Eden.com"
},
{
"name": "3rdeden",
"email": "npm@3rd-Eden.com"
}
],
"name": "requires-port",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/unshiftio/requires-port.git"
},
"scripts": {
"100%": "istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100",
"coverage": "istanbul cover _mocha -- test.js",
"test": "mocha test.js",
"test-travis": "istanbul cover _mocha --report lcovonly -- test.js",
"watch": "mocha --watch test.js"
},
"version": "1.0.0"
}

View File

@@ -0,0 +1,98 @@
describe('requires-port', function () {
'use strict';
var assume = require('assume')
, required = require('./');
it('is exported as a function', function () {
assume(required).is.a('function');
});
it('does not require empty ports', function () {
assume(required('', 'http')).false();
assume(required('', 'wss')).false();
assume(required('', 'ws')).false();
assume(required('', 'cowsack')).false();
});
it('assumes true for unknown protocols',function () {
assume(required('808', 'foo')).true();
assume(required('80', 'bar')).true();
});
it('never requires port numbers for file', function () {
assume(required(8080, 'file')).false();
});
it('does not require port 80 for http', function () {
assume(required('80', 'http')).false();
assume(required(80, 'http')).false();
assume(required(80, 'http://')).false();
assume(required(80, 'http://www.google.com')).false();
assume(required('8080', 'http')).true();
assume(required(8080, 'http')).true();
assume(required(8080, 'http://')).true();
assume(required(8080, 'http://www.google.com')).true();
});
it('does not require port 80 for ws', function () {
assume(required('80', 'ws')).false();
assume(required(80, 'ws')).false();
assume(required(80, 'ws://')).false();
assume(required(80, 'ws://www.google.com')).false();
assume(required('8080', 'ws')).true();
assume(required(8080, 'ws')).true();
assume(required(8080, 'ws://')).true();
assume(required(8080, 'ws://www.google.com')).true();
});
it('does not require port 443 for https', function () {
assume(required('443', 'https')).false();
assume(required(443, 'https')).false();
assume(required(443, 'https://')).false();
assume(required(443, 'https://www.google.com')).false();
assume(required('8080', 'https')).true();
assume(required(8080, 'https')).true();
assume(required(8080, 'https://')).true();
assume(required(8080, 'https://www.google.com')).true();
});
it('does not require port 443 for wss', function () {
assume(required('443', 'wss')).false();
assume(required(443, 'wss')).false();
assume(required(443, 'wss://')).false();
assume(required(443, 'wss://www.google.com')).false();
assume(required('8080', 'wss')).true();
assume(required(8080, 'wss')).true();
assume(required(8080, 'wss://')).true();
assume(required(8080, 'wss://www.google.com')).true();
});
it('does not require port 21 for ftp', function () {
assume(required('21', 'ftp')).false();
assume(required(21, 'ftp')).false();
assume(required(21, 'ftp://')).false();
assume(required(21, 'ftp://www.google.com')).false();
assume(required('8080', 'ftp')).true();
assume(required(8080, 'ftp')).true();
assume(required(8080, 'ftp://')).true();
assume(required(8080, 'ftp://www.google.com')).true();
});
it('does not require port 70 for gopher', function () {
assume(required('70', 'gopher')).false();
assume(required(70, 'gopher')).false();
assume(required(70, 'gopher://')).false();
assume(required(70, 'gopher://www.google.com')).false();
assume(required('8080', 'gopher')).true();
assume(required(8080, 'gopher')).true();
assume(required(8080, 'gopher://')).true();
assume(required(8080, 'gopher://www.google.com')).true();
});
});