aboutsummaryrefslogtreecommitdiff
path: root/node_modules/normalize-url
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/normalize-url')
-rw-r--r--node_modules/normalize-url/index.js161
-rw-r--r--node_modules/normalize-url/license21
-rw-r--r--node_modules/normalize-url/package.json50
-rw-r--r--node_modules/normalize-url/readme.md156
4 files changed, 0 insertions, 388 deletions
diff --git a/node_modules/normalize-url/index.js b/node_modules/normalize-url/index.js
deleted file mode 100644
index f4aa1814..00000000
--- a/node_modules/normalize-url/index.js
+++ /dev/null
@@ -1,161 +0,0 @@
-'use strict';
-var url = require('url');
-var punycode = require('punycode');
-var queryString = require('query-string');
-var prependHttp = require('prepend-http');
-var sortKeys = require('sort-keys');
-var objectAssign = require('object-assign');
-
-var DEFAULT_PORTS = {
- 'http:': 80,
- 'https:': 443,
- 'ftp:': 21
-};
-
-// protocols that always contain a `//`` bit
-var slashedProtocol = {
- 'http': true,
- 'https': true,
- 'ftp': true,
- 'gopher': true,
- 'file': true,
- 'http:': true,
- 'https:': true,
- 'ftp:': true,
- 'gopher:': true,
- 'file:': true
-};
-
-function testParameter(name, filters) {
- return filters.some(function (filter) {
- return filter instanceof RegExp ? filter.test(name) : filter === name;
- });
-}
-
-module.exports = function (str, opts) {
- opts = objectAssign({
- normalizeProtocol: true,
- normalizeHttps: false,
- stripFragment: true,
- stripWWW: true,
- removeQueryParameters: [/^utm_\w+/i],
- removeTrailingSlash: true,
- removeDirectoryIndex: false
- }, opts);
-
- if (typeof str !== 'string') {
- throw new TypeError('Expected a string');
- }
-
- var hasRelativeProtocol = str.indexOf('//') === 0;
-
- // prepend protocol
- str = prependHttp(str.trim()).replace(/^\/\//, 'http://');
-
- var urlObj = url.parse(str);
-
- if (opts.normalizeHttps && urlObj.protocol === 'https:') {
- urlObj.protocol = 'http:';
- }
-
- if (!urlObj.hostname && !urlObj.pathname) {
- throw new Error('Invalid URL');
- }
-
- // prevent these from being used by `url.format`
- delete urlObj.host;
- delete urlObj.query;
-
- // remove fragment
- if (opts.stripFragment) {
- delete urlObj.hash;
- }
-
- // remove default port
- var port = DEFAULT_PORTS[urlObj.protocol];
- if (Number(urlObj.port) === port) {
- delete urlObj.port;
- }
-
- // remove duplicate slashes
- if (urlObj.pathname) {
- urlObj.pathname = urlObj.pathname.replace(/\/{2,}/g, '/');
- }
-
- // decode URI octets
- if (urlObj.pathname) {
- urlObj.pathname = decodeURI(urlObj.pathname);
- }
-
- // remove directory index
- if (opts.removeDirectoryIndex === true) {
- opts.removeDirectoryIndex = [/^index\.[a-z]+$/];
- }
-
- if (Array.isArray(opts.removeDirectoryIndex) && opts.removeDirectoryIndex.length) {
- var pathComponents = urlObj.pathname.split('/');
- var lastComponent = pathComponents[pathComponents.length - 1];
-
- if (testParameter(lastComponent, opts.removeDirectoryIndex)) {
- pathComponents = pathComponents.slice(0, pathComponents.length - 1);
- urlObj.pathname = pathComponents.slice(1).join('/') + '/';
- }
- }
-
- // resolve relative paths, but only for slashed protocols
- if (slashedProtocol[urlObj.protocol]) {
- var domain = urlObj.protocol + '//' + urlObj.hostname;
- var relative = url.resolve(domain, urlObj.pathname);
- urlObj.pathname = relative.replace(domain, '');
- }
-
- if (urlObj.hostname) {
- // IDN to Unicode
- urlObj.hostname = punycode.toUnicode(urlObj.hostname).toLowerCase();
-
- // remove trailing dot
- urlObj.hostname = urlObj.hostname.replace(/\.$/, '');
-
- // remove `www.`
- if (opts.stripWWW) {
- urlObj.hostname = urlObj.hostname.replace(/^www\./, '');
- }
- }
-
- // remove URL with empty query string
- if (urlObj.search === '?') {
- delete urlObj.search;
- }
-
- var queryParameters = queryString.parse(urlObj.search);
-
- // remove query unwanted parameters
- if (Array.isArray(opts.removeQueryParameters)) {
- for (var key in queryParameters) {
- if (testParameter(key, opts.removeQueryParameters)) {
- delete queryParameters[key];
- }
- }
- }
-
- // sort query parameters
- urlObj.search = queryString.stringify(sortKeys(queryParameters));
-
- // decode query parameters
- urlObj.search = decodeURIComponent(urlObj.search);
-
- // take advantage of many of the Node `url` normalizations
- str = url.format(urlObj);
-
- // remove ending `/`
- if (opts.removeTrailingSlash || urlObj.pathname === '/') {
- str = str.replace(/\/$/, '');
- }
-
- // restore relative protocol, if applicable
- if (hasRelativeProtocol && !opts.normalizeProtocol) {
- str = str.replace(/^http:\/\//, '//');
- }
-
- return str;
-};
diff --git a/node_modules/normalize-url/license b/node_modules/normalize-url/license
deleted file mode 100644
index 654d0bfe..00000000
--- a/node_modules/normalize-url/license
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.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.
diff --git a/node_modules/normalize-url/package.json b/node_modules/normalize-url/package.json
deleted file mode 100644
index b255039b..00000000
--- a/node_modules/normalize-url/package.json
+++ /dev/null
@@ -1,50 +0,0 @@
-{
- "name": "normalize-url",
- "version": "1.9.1",
- "description": "Normalize a URL",
- "license": "MIT",
- "repository": "sindresorhus/normalize-url",
- "author": {
- "name": "Sindre Sorhus",
- "email": "sindresorhus@gmail.com",
- "url": "sindresorhus.com"
- },
- "engines": {
- "node": ">=4"
- },
- "scripts": {
- "test": "xo && ava"
- },
- "files": [
- "index.js"
- ],
- "keywords": [
- "normalize",
- "url",
- "uri",
- "address",
- "string",
- "str",
- "normalise",
- "normalization",
- "normalisation",
- "query",
- "string",
- "querystring",
- "unicode",
- "simplify",
- "strip",
- "trim",
- "canonical"
- ],
- "dependencies": {
- "object-assign": "^4.0.1",
- "prepend-http": "^1.0.0",
- "query-string": "^4.1.0",
- "sort-keys": "^1.0.0"
- },
- "devDependencies": {
- "ava": "*",
- "xo": "^0.16.0"
- }
-}
diff --git a/node_modules/normalize-url/readme.md b/node_modules/normalize-url/readme.md
deleted file mode 100644
index 51f624aa..00000000
--- a/node_modules/normalize-url/readme.md
+++ /dev/null
@@ -1,156 +0,0 @@
-# normalize-url [![Build Status](https://travis-ci.org/sindresorhus/normalize-url.svg?branch=master)](https://travis-ci.org/sindresorhus/normalize-url)
-
-> [Normalize](http://en.wikipedia.org/wiki/URL_normalization) a URL
-
-Useful when you need to display, store, deduplicate, sort, compare, etc, URLs.
-
-
-## Install
-
-```
-$ npm install --save normalize-url
-```
-
-
-## Usage
-
-```js
-const normalizeUrl = require('normalize-url');
-
-normalizeUrl('sindresorhus.com');
-//=> 'http://sindresorhus.com'
-
-normalizeUrl('HTTP://xn--xample-hva.com:80/?b=bar&a=foo');
-//=> 'http://êxample.com/?a=foo&b=bar'
-```
-
-
-## API
-
-### normalizeUrl(url, [options])
-
-#### url
-
-Type: `string`
-
-URL to normalize.
-
-#### options
-
-##### normalizeProtocol
-
-Type: `boolean`<br>
-Default: `true`
-
-Prepend `http:` to the URL if it's protocol-relative.
-
-```js
-normalizeUrl('//sindresorhus.com:80/');
-//=> 'http://sindresorhus.com'
-
-normalizeUrl('//sindresorhus.com:80/', {normalizeProtocol: false});
-//=> '//sindresorhus.com'
-```
-
-##### normalizeHttps
-
-Type: `boolean`<br>
-Default: `false`
-
-Normalize `https:` URLs to `http:`.
-
-```js
-normalizeUrl('https://sindresorhus.com:80/');
-//=> 'https://sindresorhus.com'
-
-normalizeUrl('https://sindresorhus.com:80/', {normalizeHttps: true});
-//=> 'http://sindresorhus.com'
-```
-
-##### stripFragment
-
-Type: `boolean`<br>
-Default: `true`
-
-Remove the fragment at the end of the URL.
-
-```js
-normalizeUrl('sindresorhus.com/about.html#contact');
-//=> 'http://sindresorhus.com/about.html'
-
-normalizeUrl('sindresorhus.com/about.html#contact', {stripFragment: false});
-//=> 'http://sindresorhus.com/about.html#contact'
-```
-
-##### stripWWW
-
-Type: `boolean`<br>
-Default: `true`
-
-Remove `www.` from the URL.
-
-```js
-normalizeUrl('http://www.sindresorhus.com/about.html#contact');
-//=> 'http://sindresorhus.com/about.html#contact'
-
-normalizeUrl('http://www.sindresorhus.com/about.html#contact', {stripWWW: false});
-//=> 'http://www.sindresorhus.com/about.html#contact'
-```
-
-##### removeQueryParameters
-
-Type: `Array<RegExp|string>`<br>
-Default: `[/^utm_\w+/i]`
-
-Remove query parameters that matches any of the provided strings or regexes.
-
-```js
-normalizeUrl('www.sindresorhus.com?foo=bar&ref=test_ref', {
- removeQueryParameters: ['ref']
-});
-//=> 'http://sindresorhus.com/?foo=bar'
-```
-
-##### removeTrailingSlash
-
-Type: `boolean`<br>
-Default: `true`
-
-Remove trailing slash.
-
-**Note:** Trailing slash is always removed if the URL doesn't have a pathname.
-
-```js
-normalizeUrl('http://sindresorhus.com/redirect/');
-//=> 'http://sindresorhus.com/redirect'
-
-normalizeUrl('http://sindresorhus.com/redirect/', {removeTrailingSlash: false});
-//=> 'http://sindresorhus.com/redirect/'
-
-normalizeUrl('http://sindresorhus.com/', {removeTrailingSlash: false});
-//=> 'http://sindresorhus.com'
-```
-
-##### removeDirectoryIndex
-
-Type: `boolean` `Array<RegExp|string>`<br>
-Default: `false`
-
-Remove the default directory index file from path that matches any of the provided strings or regexes. When `true`, the regex `/^index\.[a-z]+$/` is used.
-
-```js
-normalizeUrl('www.sindresorhus.com/foo/default.php', {
- removeDirectoryIndex: [/^default\.[a-z]+$/]
-});
-//=> 'http://sindresorhus.com/foo'
-```
-
-
-## Related
-
-- [compare-urls](https://github.com/sindresorhus/compare-urls) - Compare URLs by first normalizing them
-
-
-## License
-
-MIT © [Sindre Sorhus](https://sindresorhus.com)