unit tests, and some cleaning up

This commit is contained in:
Josh Burman
2019-03-14 10:14:42 -04:00
parent 501a14d713
commit 21f77fa4c3
134 changed files with 16787 additions and 359 deletions

2
node_modules/requires-port/.npmignore generated vendored Normal file
View File

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

19
node_modules/requires-port/.travis.yml generated vendored Normal file
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

22
node_modules/requires-port/LICENSE generated vendored Normal file
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.

47
node_modules/requires-port/README.md generated vendored Normal file
View File

@ -0,0 +1,47 @@
# requires-port
[![Made by unshift](https://img.shields.io/badge/made%20by-unshift-00ffcc.svg?style=flat-square)](http://unshift.io)[![Version npm](http://img.shields.io/npm/v/requires-port.svg?style=flat-square)](http://browsenpm.org/package/requires-port)[![Build Status](http://img.shields.io/travis/unshiftio/requires-port/master.svg?style=flat-square)](https://travis-ci.org/unshiftio/requires-port)[![Dependencies](https://img.shields.io/david/unshiftio/requires-port.svg?style=flat-square)](https://david-dm.org/unshiftio/requires-port)[![Coverage Status](http://img.shields.io/coveralls/unshiftio/requires-port/master.svg?style=flat-square)](https://coveralls.io/r/unshiftio/requires-port?branch=master)[![IRC channel](http://img.shields.io/badge/IRC-irc.freenode.net%23unshift-00a8ff.svg?style=flat-square)](http://webchat.freenode.net/?channels=unshift)
The module name says it all, check if a protocol requires a given port.
## Installation
This module is intended to be used with browserify or Node.js and is distributed
in the public npm registry. To install it simply run the following command from
your CLI:
```j
npm install --save requires-port
```
## Usage
The module exports it self as function and requires 2 arguments:
1. The port number, can be a string or number.
2. Protocol, can be `http`, `http:` or even `https://yomoma.com`. We just split
it at `:` and use the first result. We currently accept the following
protocols:
- `http`
- `https`
- `ws`
- `wss`
- `ftp`
- `gopher`
- `file`
It returns a boolean that indicates if protocol requires this port to be added
to your URL.
```js
'use strict';
var required = require('requires-port');
console.log(required('8080', 'http')) // true
console.log(required('80', 'http')) // false
```
# License
MIT

38
node_modules/requires-port/index.js generated vendored Normal file
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;
};

74
node_modules/requires-port/package.json generated vendored Normal file
View File

@ -0,0 +1,74 @@
{
"_from": "requires-port@^1.0.0",
"_id": "requires-port@1.0.0",
"_inBundle": false,
"_integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=",
"_location": "/requires-port",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "requires-port@^1.0.0",
"name": "requires-port",
"escapedName": "requires-port",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/url-parse"
],
"_resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
"_shasum": "925d2601d39ac485e091cf0da5c6e694dc3dcaff",
"_spec": "requires-port@^1.0.0",
"_where": "/Users/josh.burman/Projects/braid/node_modules/url-parse",
"author": {
"name": "Arnout Kazemier"
},
"bugs": {
"url": "https://github.com/unshiftio/requires-port/issues"
},
"bundleDependencies": false,
"deprecated": false,
"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"
},
"homepage": "https://github.com/unshiftio/requires-port",
"keywords": [
"port",
"require",
"http",
"https",
"ws",
"wss",
"gopher",
"file",
"ftp",
"requires",
"requried",
"portnumber",
"url",
"parsing",
"validation",
"cows"
],
"license": "MIT",
"main": "index.js",
"name": "requires-port",
"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"
}

98
node_modules/requires-port/test.js generated vendored Normal file
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();
});
});