mirror of
https://github.com/shimataro/ssh-key-action.git
synced 2025-06-19 22:52:10 +10:00
* first action! (#1)
This commit is contained in:
parent
8deacc95b1
commit
ace1e6a69a
3750 changed files with 1155519 additions and 0 deletions
216
node_modules/normalize-url/index.d.ts
generated
vendored
Normal file
216
node_modules/normalize-url/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,216 @@
|
|||
declare namespace normalizeUrl {
|
||||
interface Options {
|
||||
/**
|
||||
@default 'http:'
|
||||
*/
|
||||
readonly defaultProtocol?: string;
|
||||
|
||||
/**
|
||||
Prepends `defaultProtocol` to the URL if it's protocol-relative.
|
||||
|
||||
@default true
|
||||
|
||||
@example
|
||||
```
|
||||
normalizeUrl('//sindresorhus.com:80/');
|
||||
//=> 'http://sindresorhus.com'
|
||||
|
||||
normalizeUrl('//sindresorhus.com:80/', {normalizeProtocol: false});
|
||||
//=> '//sindresorhus.com'
|
||||
```
|
||||
*/
|
||||
readonly normalizeProtocol?: boolean;
|
||||
|
||||
/**
|
||||
Normalizes `https:` URLs to `http:`.
|
||||
|
||||
@default false
|
||||
|
||||
@example
|
||||
```
|
||||
normalizeUrl('https://sindresorhus.com:80/');
|
||||
//=> 'https://sindresorhus.com'
|
||||
|
||||
normalizeUrl('https://sindresorhus.com:80/', {forceHttp: true});
|
||||
//=> 'http://sindresorhus.com'
|
||||
```
|
||||
*/
|
||||
readonly forceHttp?: boolean;
|
||||
|
||||
/**
|
||||
Normalizes `http:` URLs to `https:`.
|
||||
|
||||
This option can't be used with the `forceHttp` option at the same time.
|
||||
|
||||
@default false
|
||||
|
||||
@example
|
||||
```
|
||||
normalizeUrl('https://sindresorhus.com:80/');
|
||||
//=> 'https://sindresorhus.com'
|
||||
|
||||
normalizeUrl('http://sindresorhus.com:80/', {forceHttps: true});
|
||||
//=> 'https://sindresorhus.com'
|
||||
```
|
||||
*/
|
||||
readonly forceHttps?: boolean;
|
||||
|
||||
/**
|
||||
Strip the [authentication](https://en.wikipedia.org/wiki/Basic_access_authentication) part of a URL.
|
||||
|
||||
@default true
|
||||
|
||||
@example
|
||||
```
|
||||
normalizeUrl('user:password@sindresorhus.com');
|
||||
//=> 'https://sindresorhus.com'
|
||||
|
||||
normalizeUrl('user:password@sindresorhus.com', {stripAuthentication: false});
|
||||
//=> 'https://user:password@sindresorhus.com'
|
||||
```
|
||||
*/
|
||||
readonly stripAuthentication?: boolean;
|
||||
|
||||
/**
|
||||
Removes hash from the URL.
|
||||
|
||||
@default false
|
||||
|
||||
@example
|
||||
```
|
||||
normalizeUrl('sindresorhus.com/about.html#contact');
|
||||
//=> 'http://sindresorhus.com/about.html#contact'
|
||||
|
||||
normalizeUrl('sindresorhus.com/about.html#contact', {stripHash: true});
|
||||
//=> 'http://sindresorhus.com/about.html'
|
||||
```
|
||||
*/
|
||||
readonly stripHash?: boolean;
|
||||
|
||||
/**
|
||||
Removes HTTP(S) protocol from an URL `http://sindresorhus.com` → `sindresorhus.com`.
|
||||
|
||||
@default false
|
||||
|
||||
@example
|
||||
```
|
||||
normalizeUrl('https://sindresorhus.com');
|
||||
//=> 'https://sindresorhus.com'
|
||||
|
||||
normalizeUrl('sindresorhus.com', {stripProtocol: true});
|
||||
//=> 'sindresorhus.com'
|
||||
```
|
||||
*/
|
||||
readonly stripProtocol?: boolean;
|
||||
|
||||
/**
|
||||
Removes `www.` from the URL.
|
||||
|
||||
@default true
|
||||
|
||||
@example
|
||||
```
|
||||
normalizeUrl('http://www.sindresorhus.com');
|
||||
//=> 'http://sindresorhus.com'
|
||||
|
||||
normalizeUrl('http://www.sindresorhus.com', {stripWWW: false});
|
||||
//=> 'http://www.sindresorhus.com'
|
||||
```
|
||||
*/
|
||||
readonly stripWWW?: boolean;
|
||||
|
||||
/**
|
||||
Removes query parameters that matches any of the provided strings or regexes.
|
||||
|
||||
@default [/^utm_\w+/i]
|
||||
|
||||
@example
|
||||
```
|
||||
normalizeUrl('www.sindresorhus.com?foo=bar&ref=test_ref', {
|
||||
removeQueryParameters: ['ref']
|
||||
});
|
||||
//=> 'http://sindresorhus.com/?foo=bar'
|
||||
```
|
||||
*/
|
||||
readonly removeQueryParameters?: (RegExp | string)[];
|
||||
|
||||
/**
|
||||
Removes trailing slash.
|
||||
|
||||
__Note__: Trailing slash is always removed if the URL doesn't have a pathname.
|
||||
|
||||
@default true
|
||||
|
||||
@example
|
||||
```
|
||||
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'
|
||||
```
|
||||
*/
|
||||
readonly removeTrailingSlash?: boolean;
|
||||
|
||||
/**
|
||||
Removes 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.
|
||||
|
||||
@default false
|
||||
|
||||
@example
|
||||
```
|
||||
normalizeUrl('www.sindresorhus.com/foo/default.php', {
|
||||
removeDirectoryIndex: [/^default\.[a-z]+$/]
|
||||
});
|
||||
//=> 'http://sindresorhus.com/foo'
|
||||
```
|
||||
*/
|
||||
readonly removeDirectoryIndex?: (RegExp | string)[];
|
||||
|
||||
/**
|
||||
Sorts the query parameters alphabetically by key.
|
||||
|
||||
@default true
|
||||
|
||||
@example
|
||||
```
|
||||
normalizeUrl('www.sindresorhus.com?b=two&a=one&c=three', {
|
||||
sortQueryParameters: false
|
||||
});
|
||||
//=> 'http://sindresorhus.com/?b=two&a=one&c=three'
|
||||
```
|
||||
*/
|
||||
readonly sortQueryParameters?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare const normalizeUrl: {
|
||||
/**
|
||||
[Normalize](https://en.wikipedia.org/wiki/URL_normalization) a URL.
|
||||
|
||||
@param url - URL to normalize.
|
||||
|
||||
@example
|
||||
```
|
||||
import 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'
|
||||
```
|
||||
*/
|
||||
(url: string, options?: normalizeUrl.Options): string;
|
||||
|
||||
// TODO: Remove this for the next major release, refactor the whole definition to:
|
||||
// declare function normalizeUrl(url: string, options?: normalizeUrl.Options): string;
|
||||
// export = normalizeUrl;
|
||||
default: typeof normalizeUrl;
|
||||
};
|
||||
|
||||
export = normalizeUrl;
|
160
node_modules/normalize-url/index.js
generated
vendored
Normal file
160
node_modules/normalize-url/index.js
generated
vendored
Normal file
|
@ -0,0 +1,160 @@
|
|||
'use strict';
|
||||
// TODO: Use the `URL` global when targeting Node.js 10
|
||||
const URLParser = typeof URL === 'undefined' ? require('url').URL : URL;
|
||||
|
||||
const testParameter = (name, filters) => {
|
||||
return filters.some(filter => filter instanceof RegExp ? filter.test(name) : filter === name);
|
||||
};
|
||||
|
||||
const normalizeUrl = (urlString, options) => {
|
||||
options = {
|
||||
defaultProtocol: 'http:',
|
||||
normalizeProtocol: true,
|
||||
forceHttp: false,
|
||||
forceHttps: false,
|
||||
stripAuthentication: true,
|
||||
stripHash: false,
|
||||
stripWWW: true,
|
||||
removeQueryParameters: [/^utm_\w+/i],
|
||||
removeTrailingSlash: true,
|
||||
removeDirectoryIndex: false,
|
||||
sortQueryParameters: true,
|
||||
...options
|
||||
};
|
||||
|
||||
// TODO: Remove this at some point in the future
|
||||
if (Reflect.has(options, 'normalizeHttps')) {
|
||||
throw new Error('options.normalizeHttps is renamed to options.forceHttp');
|
||||
}
|
||||
|
||||
if (Reflect.has(options, 'normalizeHttp')) {
|
||||
throw new Error('options.normalizeHttp is renamed to options.forceHttps');
|
||||
}
|
||||
|
||||
if (Reflect.has(options, 'stripFragment')) {
|
||||
throw new Error('options.stripFragment is renamed to options.stripHash');
|
||||
}
|
||||
|
||||
urlString = urlString.trim();
|
||||
|
||||
const hasRelativeProtocol = urlString.startsWith('//');
|
||||
const isRelativeUrl = !hasRelativeProtocol && /^\.*\//.test(urlString);
|
||||
|
||||
// Prepend protocol
|
||||
if (!isRelativeUrl) {
|
||||
urlString = urlString.replace(/^(?!(?:\w+:)?\/\/)|^\/\//, options.defaultProtocol);
|
||||
}
|
||||
|
||||
const urlObj = new URLParser(urlString);
|
||||
|
||||
if (options.forceHttp && options.forceHttps) {
|
||||
throw new Error('The `forceHttp` and `forceHttps` options cannot be used together');
|
||||
}
|
||||
|
||||
if (options.forceHttp && urlObj.protocol === 'https:') {
|
||||
urlObj.protocol = 'http:';
|
||||
}
|
||||
|
||||
if (options.forceHttps && urlObj.protocol === 'http:') {
|
||||
urlObj.protocol = 'https:';
|
||||
}
|
||||
|
||||
// Remove auth
|
||||
if (options.stripAuthentication) {
|
||||
urlObj.username = '';
|
||||
urlObj.password = '';
|
||||
}
|
||||
|
||||
// Remove hash
|
||||
if (options.stripHash) {
|
||||
urlObj.hash = '';
|
||||
}
|
||||
|
||||
// Remove duplicate slashes if not preceded by a protocol
|
||||
if (urlObj.pathname) {
|
||||
// TODO: Use the following instead when targeting Node.js 10
|
||||
// `urlObj.pathname = urlObj.pathname.replace(/(?<!https?:)\/{2,}/g, '/');`
|
||||
urlObj.pathname = urlObj.pathname.replace(/((?!:).|^)\/{2,}/g, (_, p1) => {
|
||||
if (/^(?!\/)/g.test(p1)) {
|
||||
return `${p1}/`;
|
||||
}
|
||||
|
||||
return '/';
|
||||
});
|
||||
}
|
||||
|
||||
// Decode URI octets
|
||||
if (urlObj.pathname) {
|
||||
urlObj.pathname = decodeURI(urlObj.pathname);
|
||||
}
|
||||
|
||||
// Remove directory index
|
||||
if (options.removeDirectoryIndex === true) {
|
||||
options.removeDirectoryIndex = [/^index\.[a-z]+$/];
|
||||
}
|
||||
|
||||
if (Array.isArray(options.removeDirectoryIndex) && options.removeDirectoryIndex.length > 0) {
|
||||
let pathComponents = urlObj.pathname.split('/');
|
||||
const lastComponent = pathComponents[pathComponents.length - 1];
|
||||
|
||||
if (testParameter(lastComponent, options.removeDirectoryIndex)) {
|
||||
pathComponents = pathComponents.slice(0, pathComponents.length - 1);
|
||||
urlObj.pathname = pathComponents.slice(1).join('/') + '/';
|
||||
}
|
||||
}
|
||||
|
||||
if (urlObj.hostname) {
|
||||
// Remove trailing dot
|
||||
urlObj.hostname = urlObj.hostname.replace(/\.$/, '');
|
||||
|
||||
// Remove `www.`
|
||||
if (options.stripWWW && /^www\.([a-z\-\d]{2,63})\.([a-z.]{2,5})$/.test(urlObj.hostname)) {
|
||||
// Each label should be max 63 at length (min: 2).
|
||||
// The extension should be max 5 at length (min: 2).
|
||||
// Source: https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names
|
||||
urlObj.hostname = urlObj.hostname.replace(/^www\./, '');
|
||||
}
|
||||
}
|
||||
|
||||
// Remove query unwanted parameters
|
||||
if (Array.isArray(options.removeQueryParameters)) {
|
||||
for (const key of [...urlObj.searchParams.keys()]) {
|
||||
if (testParameter(key, options.removeQueryParameters)) {
|
||||
urlObj.searchParams.delete(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort query parameters
|
||||
if (options.sortQueryParameters) {
|
||||
urlObj.searchParams.sort();
|
||||
}
|
||||
|
||||
if (options.removeTrailingSlash) {
|
||||
urlObj.pathname = urlObj.pathname.replace(/\/$/, '');
|
||||
}
|
||||
|
||||
// Take advantage of many of the Node `url` normalizations
|
||||
urlString = urlObj.toString();
|
||||
|
||||
// Remove ending `/`
|
||||
if ((options.removeTrailingSlash || urlObj.pathname === '/') && urlObj.hash === '') {
|
||||
urlString = urlString.replace(/\/$/, '');
|
||||
}
|
||||
|
||||
// Restore relative protocol, if applicable
|
||||
if (hasRelativeProtocol && !options.normalizeProtocol) {
|
||||
urlString = urlString.replace(/^http:\/\//, '//');
|
||||
}
|
||||
|
||||
// Remove http/https
|
||||
if (options.stripProtocol) {
|
||||
urlString = urlString.replace(/^(?:https?:)?\/\//, '');
|
||||
}
|
||||
|
||||
return urlString;
|
||||
};
|
||||
|
||||
module.exports = normalizeUrl;
|
||||
// TODO: Remove this for the next major release
|
||||
module.exports.default = normalizeUrl;
|
9
node_modules/normalize-url/license
generated
vendored
Normal file
9
node_modules/normalize-url/license
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
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.
|
76
node_modules/normalize-url/package.json
generated
vendored
Normal file
76
node_modules/normalize-url/package.json
generated
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
{
|
||||
"_from": "normalize-url@^4.1.0",
|
||||
"_id": "normalize-url@4.3.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-0NLtR71o4k6GLP+mr6Ty34c5GA6CMoEsncKJxvQd8NzPxaHRJNnb5gZE8R1XF4CPIS7QPHLJ74IFszwtNVAHVQ==",
|
||||
"_location": "/normalize-url",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "normalize-url@^4.1.0",
|
||||
"name": "normalize-url",
|
||||
"escapedName": "normalize-url",
|
||||
"rawSpec": "^4.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^4.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/cacheable-request"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.3.0.tgz",
|
||||
"_shasum": "9c49e10fc1876aeb76dba88bf1b2b5d9fa57b2ee",
|
||||
"_spec": "normalize-url@^4.1.0",
|
||||
"_where": "/home/shimataro/projects/actions/ssh-key-action/node_modules/cacheable-request",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sindresorhus/normalize-url/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Normalize a URL",
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"coveralls": "^3.0.3",
|
||||
"nyc": "^13.3.0",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"homepage": "https://github.com/sindresorhus/normalize-url#readme",
|
||||
"keywords": [
|
||||
"normalize",
|
||||
"url",
|
||||
"uri",
|
||||
"address",
|
||||
"string",
|
||||
"normalization",
|
||||
"normalisation",
|
||||
"query",
|
||||
"querystring",
|
||||
"simplify",
|
||||
"strip",
|
||||
"trim",
|
||||
"canonical"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "normalize-url",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sindresorhus/normalize-url.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && nyc ava && tsd"
|
||||
},
|
||||
"version": "4.3.0"
|
||||
}
|
224
node_modules/normalize-url/readme.md
generated
vendored
Normal file
224
node_modules/normalize-url/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,224 @@
|
|||
# normalize-url [](https://travis-ci.org/sindresorhus/normalize-url) [](https://coveralls.io/github/sindresorhus/normalize-url?branch=master)
|
||||
|
||||
> [Normalize](https://en.wikipedia.org/wiki/URL_normalization) a URL
|
||||
|
||||
Useful when you need to display, store, deduplicate, sort, compare, etc, URLs.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install 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
|
||||
|
||||
Type: `Object`
|
||||
|
||||
##### defaultProtocol
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `http:`
|
||||
|
||||
##### normalizeProtocol
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Prepends `defaultProtocol` to the URL if it's protocol-relative.
|
||||
|
||||
```js
|
||||
normalizeUrl('//sindresorhus.com:80/');
|
||||
//=> 'http://sindresorhus.com'
|
||||
|
||||
normalizeUrl('//sindresorhus.com:80/', {normalizeProtocol: false});
|
||||
//=> '//sindresorhus.com'
|
||||
```
|
||||
|
||||
##### forceHttp
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Normalizes `https:` URLs to `http:`.
|
||||
|
||||
```js
|
||||
normalizeUrl('https://sindresorhus.com:80/');
|
||||
//=> 'https://sindresorhus.com'
|
||||
|
||||
normalizeUrl('https://sindresorhus.com:80/', {forceHttp: true});
|
||||
//=> 'http://sindresorhus.com'
|
||||
```
|
||||
|
||||
##### forceHttps
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Normalizes `http:` URLs to `https:`.
|
||||
|
||||
```js
|
||||
normalizeUrl('https://sindresorhus.com:80/');
|
||||
//=> 'https://sindresorhus.com'
|
||||
|
||||
normalizeUrl('http://sindresorhus.com:80/', {forceHttps: true});
|
||||
//=> 'https://sindresorhus.com'
|
||||
```
|
||||
|
||||
This option can't be used with the `forceHttp` option at the same time.
|
||||
|
||||
##### stripAuthentication
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Strip the [authentication](https://en.wikipedia.org/wiki/Basic_access_authentication) part of a URL.
|
||||
|
||||
```js
|
||||
normalizeUrl('user:password@sindresorhus.com');
|
||||
//=> 'https://sindresorhus.com'
|
||||
|
||||
normalizeUrl('user:password@sindresorhus.com', {stripAuthentication: false});
|
||||
//=> 'https://user:password@sindresorhus.com'
|
||||
```
|
||||
|
||||
##### stripHash
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Removes hash from the URL.
|
||||
|
||||
```js
|
||||
normalizeUrl('sindresorhus.com/about.html#contact');
|
||||
//=> 'http://sindresorhus.com/about.html#contact'
|
||||
|
||||
normalizeUrl('sindresorhus.com/about.html#contact', {stripHash: true});
|
||||
//=> 'http://sindresorhus.com/about.html'
|
||||
```
|
||||
|
||||
##### stripProtocol
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Removes HTTP(S) protocol from an URL `http://sindresorhus.com` → `sindresorhus.com`.
|
||||
|
||||
```js
|
||||
normalizeUrl('https://sindresorhus.com');
|
||||
//=> 'https://sindresorhus.com'
|
||||
|
||||
normalizeUrl('sindresorhus.com', {stripProtocol: true});
|
||||
//=> 'sindresorhus.com'
|
||||
```
|
||||
|
||||
##### stripWWW
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Removes `www.` from the URL.
|
||||
|
||||
```js
|
||||
normalizeUrl('http://www.sindresorhus.com');
|
||||
//=> 'http://sindresorhus.com'
|
||||
|
||||
normalizeUrl('http://www.sindresorhus.com', {stripWWW: false});
|
||||
//=> 'http://www.sindresorhus.com'
|
||||
```
|
||||
|
||||
##### removeQueryParameters
|
||||
|
||||
Type: `Array<RegExp|string>`<br>
|
||||
Default: `[/^utm_\w+/i]`
|
||||
|
||||
Removes 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`
|
||||
|
||||
Removes 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`
|
||||
|
||||
Removes 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'
|
||||
```
|
||||
|
||||
##### sortQueryParameters
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Sorts the query parameters alphabetically by key.
|
||||
|
||||
```js
|
||||
normalizeUrl('www.sindresorhus.com?b=two&a=one&c=three', {
|
||||
sortQueryParameters: false
|
||||
});
|
||||
//=> 'http://sindresorhus.com/?b=two&a=one&c=three'
|
||||
```
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [compare-urls](https://github.com/sindresorhus/compare-urls) - Compare URLs by first normalizing them
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
Loading…
Add table
Add a link
Reference in a new issue