vscode-uri
Advanced tools
Comparing version 2.1.2 to 3.0.0
@@ -1,643 +0,2 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
'use strict'; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var _a; | ||
var isWindows; | ||
if (typeof process === 'object') { | ||
isWindows = process.platform === 'win32'; | ||
} | ||
else if (typeof navigator === 'object') { | ||
var userAgent = navigator.userAgent; | ||
isWindows = userAgent.indexOf('Windows') >= 0; | ||
} | ||
function isHighSurrogate(charCode) { | ||
return (0xD800 <= charCode && charCode <= 0xDBFF); | ||
} | ||
function isLowSurrogate(charCode) { | ||
return (0xDC00 <= charCode && charCode <= 0xDFFF); | ||
} | ||
function isLowerAsciiHex(code) { | ||
return code >= 97 /* a */ && code <= 102 /* f */; | ||
} | ||
function isLowerAsciiLetter(code) { | ||
return code >= 97 /* a */ && code <= 122 /* z */; | ||
} | ||
function isUpperAsciiLetter(code) { | ||
return code >= 65 /* A */ && code <= 90 /* Z */; | ||
} | ||
function isAsciiLetter(code) { | ||
return isLowerAsciiLetter(code) || isUpperAsciiLetter(code); | ||
} | ||
//#endregion | ||
var _schemePattern = /^\w[\w\d+.-]*$/; | ||
var _singleSlashStart = /^\//; | ||
var _doubleSlashStart = /^\/\//; | ||
function _validateUri(ret, _strict) { | ||
// scheme, must be set | ||
if (!ret.scheme && _strict) { | ||
throw new Error("[UriError]: Scheme is missing: {scheme: \"\", authority: \"" + ret.authority + "\", path: \"" + ret.path + "\", query: \"" + ret.query + "\", fragment: \"" + ret.fragment + "\"}"); | ||
} | ||
// scheme, https://tools.ietf.org/html/rfc3986#section-3.1 | ||
// ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) | ||
if (ret.scheme && !_schemePattern.test(ret.scheme)) { | ||
throw new Error('[UriError]: Scheme contains illegal characters.'); | ||
} | ||
// path, http://tools.ietf.org/html/rfc3986#section-3.3 | ||
// If a URI contains an authority component, then the path component | ||
// must either be empty or begin with a slash ("/") character. If a URI | ||
// does not contain an authority component, then the path cannot begin | ||
// with two slash characters ("//"). | ||
if (ret.path) { | ||
if (ret.authority) { | ||
if (!_singleSlashStart.test(ret.path)) { | ||
throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character'); | ||
} | ||
} | ||
else { | ||
if (_doubleSlashStart.test(ret.path)) { | ||
throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")'); | ||
} | ||
} | ||
} | ||
} | ||
// for a while we allowed uris *without* schemes and this is the migration | ||
// for them, e.g. an uri without scheme and without strict-mode warns and falls | ||
// back to the file-scheme. that should cause the least carnage and still be a | ||
// clear warning | ||
function _schemeFix(scheme, _strict) { | ||
if (!scheme && !_strict) { | ||
return 'file'; | ||
} | ||
return scheme; | ||
} | ||
// implements a bit of https://tools.ietf.org/html/rfc3986#section-5 | ||
function _referenceResolution(scheme, path) { | ||
// the slash-character is our 'default base' as we don't | ||
// support constructing URIs relative to other URIs. This | ||
// also means that we alter and potentially break paths. | ||
// see https://tools.ietf.org/html/rfc3986#section-5.1.4 | ||
switch (scheme) { | ||
case 'https': | ||
case 'http': | ||
case 'file': | ||
if (!path) { | ||
path = _slash; | ||
} | ||
else if (path[0] !== _slash) { | ||
path = _slash + path; | ||
} | ||
break; | ||
} | ||
return path; | ||
} | ||
var _empty = ''; | ||
var _slash = '/'; | ||
var _regexp = /^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/; | ||
/** | ||
* Uniform Resource Identifier (URI) http://tools.ietf.org/html/rfc3986. | ||
* This class is a simple parser which creates the basic component parts | ||
* (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation | ||
* and encoding. | ||
* | ||
* ```txt | ||
* foo://example.com:8042/over/there?name=ferret#nose | ||
* \_/ \______________/\_________/ \_________/ \__/ | ||
* | | | | | | ||
* scheme authority path query fragment | ||
* | _____________________|__ | ||
* / \ / \ | ||
* urn:example:animal:ferret:nose | ||
* ``` | ||
*/ | ||
var URI = /** @class */ (function () { | ||
/** | ||
* @internal | ||
*/ | ||
function URI(schemeOrData, authority, path, query, fragment, _strict) { | ||
if (_strict === void 0) { _strict = false; } | ||
if (typeof schemeOrData === 'object') { | ||
this.scheme = schemeOrData.scheme || _empty; | ||
this.authority = schemeOrData.authority || _empty; | ||
this.path = schemeOrData.path || _empty; | ||
this.query = schemeOrData.query || _empty; | ||
this.fragment = schemeOrData.fragment || _empty; | ||
// no validation because it's this URI | ||
// that creates uri components. | ||
// _validateUri(this); | ||
} | ||
else { | ||
this.scheme = _schemeFix(schemeOrData, _strict); | ||
this.authority = authority || _empty; | ||
this.path = _referenceResolution(this.scheme, path || _empty); | ||
this.query = query || _empty; | ||
this.fragment = fragment || _empty; | ||
_validateUri(this, _strict); | ||
} | ||
} | ||
URI.isUri = function (thing) { | ||
if (thing instanceof URI) { | ||
return true; | ||
} | ||
if (!thing) { | ||
return false; | ||
} | ||
return typeof thing.authority === 'string' | ||
&& typeof thing.fragment === 'string' | ||
&& typeof thing.path === 'string' | ||
&& typeof thing.query === 'string' | ||
&& typeof thing.scheme === 'string' | ||
&& typeof thing.fsPath === 'function' | ||
&& typeof thing.with === 'function' | ||
&& typeof thing.toString === 'function'; | ||
}; | ||
Object.defineProperty(URI.prototype, "fsPath", { | ||
// ---- filesystem path ----------------------- | ||
/** | ||
* Returns a string representing the corresponding file system path of this URI. | ||
* Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the | ||
* platform specific path separator. | ||
* | ||
* * Will *not* validate the path for invalid characters and semantics. | ||
* * Will *not* look at the scheme of this URI. | ||
* * The result shall *not* be used for display purposes but for accessing a file on disk. | ||
* | ||
* | ||
* The *difference* to `URI#path` is the use of the platform specific separator and the handling | ||
* of UNC paths. See the below sample of a file-uri with an authority (UNC path). | ||
* | ||
* ```ts | ||
const u = URI.parse('file://server/c$/folder/file.txt') | ||
u.authority === 'server' | ||
u.path === '/shares/c$/file.txt' | ||
u.fsPath === '\\server\c$\folder\file.txt' | ||
``` | ||
* | ||
* Using `URI#path` to read a file (using fs-apis) would not be enough because parts of the path, | ||
* namely the server name, would be missing. Therefore `URI#fsPath` exists - it's sugar to ease working | ||
* with URIs that represent files on disk (`file` scheme). | ||
*/ | ||
get: function () { | ||
// if (this.scheme !== 'file') { | ||
// console.warn(`[UriError] calling fsPath with scheme ${this.scheme}`); | ||
// } | ||
return uriToFsPath(this, false); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
// ---- modify to new ------------------------- | ||
URI.prototype.with = function (change) { | ||
if (!change) { | ||
return this; | ||
} | ||
var scheme = change.scheme, authority = change.authority, path = change.path, query = change.query, fragment = change.fragment; | ||
if (scheme === undefined) { | ||
scheme = this.scheme; | ||
} | ||
else if (scheme === null) { | ||
scheme = _empty; | ||
} | ||
if (authority === undefined) { | ||
authority = this.authority; | ||
} | ||
else if (authority === null) { | ||
authority = _empty; | ||
} | ||
if (path === undefined) { | ||
path = this.path; | ||
} | ||
else if (path === null) { | ||
path = _empty; | ||
} | ||
if (query === undefined) { | ||
query = this.query; | ||
} | ||
else if (query === null) { | ||
query = _empty; | ||
} | ||
if (fragment === undefined) { | ||
fragment = this.fragment; | ||
} | ||
else if (fragment === null) { | ||
fragment = _empty; | ||
} | ||
if (scheme === this.scheme | ||
&& authority === this.authority | ||
&& path === this.path | ||
&& query === this.query | ||
&& fragment === this.fragment) { | ||
return this; | ||
} | ||
return new _URI(scheme, authority, path, query, fragment); | ||
}; | ||
// ---- parse & validate ------------------------ | ||
/** | ||
* Creates a new URI from a string, e.g. `http://www.msft.com/some/path`, | ||
* `file:///usr/home`, or `scheme:with/path`. | ||
* | ||
* @param value A string which represents an URI (see `URI#toString`). | ||
*/ | ||
URI.parse = function (value, _strict) { | ||
if (_strict === void 0) { _strict = false; } | ||
var match = _regexp.exec(value); | ||
if (!match) { | ||
return new _URI(_empty, _empty, _empty, _empty, _empty); | ||
} | ||
return new _URI(match[2] || _empty, percentDecode(match[4] || _empty), percentDecode(match[5] || _empty), percentDecode(match[7] || _empty), percentDecode(match[9] || _empty), _strict); | ||
}; | ||
/** | ||
* Creates a new URI from a file system path, e.g. `c:\my\files`, | ||
* `/usr/home`, or `\\server\share\some\path`. | ||
* | ||
* The *difference* between `URI#parse` and `URI#file` is that the latter treats the argument | ||
* as path, not as stringified-uri. E.g. `URI.file(path)` is **not the same as** | ||
* `URI.parse('file://' + path)` because the path might contain characters that are | ||
* interpreted (# and ?). See the following sample: | ||
* ```ts | ||
const good = URI.file('/coding/c#/project1'); | ||
good.scheme === 'file'; | ||
good.path === '/coding/c#/project1'; | ||
good.fragment === ''; | ||
const bad = URI.parse('file://' + '/coding/c#/project1'); | ||
bad.scheme === 'file'; | ||
bad.path === '/coding/c'; // path is now broken | ||
bad.fragment === '/project1'; | ||
``` | ||
* | ||
* @param path A file system path (see `URI#fsPath`) | ||
*/ | ||
URI.file = function (path) { | ||
var authority = _empty; | ||
// normalize to fwd-slashes on windows, | ||
// on other systems bwd-slashes are valid | ||
// filename character, eg /f\oo/ba\r.txt | ||
if (isWindows) { | ||
path = path.replace(/\\/g, _slash); | ||
} | ||
// check for authority as used in UNC shares | ||
// or use the path as given | ||
if (path[0] === _slash && path[1] === _slash) { | ||
var idx = path.indexOf(_slash, 2); | ||
if (idx === -1) { | ||
authority = path.substring(2); | ||
path = _slash; | ||
} | ||
else { | ||
authority = path.substring(2, idx); | ||
path = path.substring(idx) || _slash; | ||
} | ||
} | ||
return new _URI('file', authority, path, _empty, _empty); | ||
}; | ||
URI.from = function (components) { | ||
return new _URI(components.scheme, components.authority, components.path, components.query, components.fragment); | ||
}; | ||
// /** | ||
// * Join a URI path with path fragments and normalizes the resulting path. | ||
// * | ||
// * @param uri The input URI. | ||
// * @param pathFragment The path fragment to add to the URI path. | ||
// * @returns The resulting URI. | ||
// */ | ||
// static joinPath(uri: URI, ...pathFragment: string[]): URI { | ||
// if (!uri.path) { | ||
// throw new Error(`[UriError]: cannot call joinPaths on URI without path`); | ||
// } | ||
// let newPath: string; | ||
// if (isWindows && uri.scheme === 'file') { | ||
// newPath = URI.file(paths.win32.join(uriToFsPath(uri, true), ...pathFragment)).path; | ||
// } else { | ||
// newPath = paths.posix.join(uri.path, ...pathFragment); | ||
// } | ||
// return uri.with({ path: newPath }); | ||
// } | ||
// ---- printing/externalize --------------------------- | ||
/** | ||
* Creates a string representation for this URI. It's guaranteed that calling | ||
* `URI.parse` with the result of this function creates an URI which is equal | ||
* to this URI. | ||
* | ||
* * The result shall *not* be used for display purposes but for externalization or transport. | ||
* * The result will be encoded using the percentage encoding and encoding happens mostly | ||
* ignore the scheme-specific encoding rules. | ||
* | ||
* @param skipEncoding Do not encode the result, default is `false` | ||
*/ | ||
URI.prototype.toString = function (skipEncoding) { | ||
if (skipEncoding === void 0) { skipEncoding = false; } | ||
return _asFormatted(this, skipEncoding); | ||
}; | ||
URI.prototype.toJSON = function () { | ||
return this; | ||
}; | ||
URI.revive = function (data) { | ||
if (!data) { | ||
return data; | ||
} | ||
else if (data instanceof URI) { | ||
return data; | ||
} | ||
else { | ||
var result = new _URI(data); | ||
result._formatted = data.external; | ||
result._fsPath = data._sep === _pathSepMarker ? data.fsPath : null; | ||
return result; | ||
} | ||
}; | ||
return URI; | ||
}()); | ||
export { URI }; | ||
var _pathSepMarker = isWindows ? 1 : undefined; | ||
// eslint-disable-next-line @typescript-eslint/class-name-casing | ||
var _URI = /** @class */ (function (_super) { | ||
__extends(_URI, _super); | ||
function _URI() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this._formatted = null; | ||
_this._fsPath = null; | ||
return _this; | ||
} | ||
Object.defineProperty(_URI.prototype, "fsPath", { | ||
get: function () { | ||
if (!this._fsPath) { | ||
this._fsPath = uriToFsPath(this, false); | ||
} | ||
return this._fsPath; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
_URI.prototype.toString = function (skipEncoding) { | ||
if (skipEncoding === void 0) { skipEncoding = false; } | ||
if (!skipEncoding) { | ||
if (!this._formatted) { | ||
this._formatted = _asFormatted(this, false); | ||
} | ||
return this._formatted; | ||
} | ||
else { | ||
// we don't cache that | ||
return _asFormatted(this, true); | ||
} | ||
}; | ||
_URI.prototype.toJSON = function () { | ||
var res = { | ||
$mid: 1 | ||
}; | ||
// cached state | ||
if (this._fsPath) { | ||
res.fsPath = this._fsPath; | ||
res._sep = _pathSepMarker; | ||
} | ||
if (this._formatted) { | ||
res.external = this._formatted; | ||
} | ||
// uri components | ||
if (this.path) { | ||
res.path = this.path; | ||
} | ||
if (this.scheme) { | ||
res.scheme = this.scheme; | ||
} | ||
if (this.authority) { | ||
res.authority = this.authority; | ||
} | ||
if (this.query) { | ||
res.query = this.query; | ||
} | ||
if (this.fragment) { | ||
res.fragment = this.fragment; | ||
} | ||
return res; | ||
}; | ||
return _URI; | ||
}(URI)); | ||
// reserved characters: https://tools.ietf.org/html/rfc3986#section-2.2 | ||
var encodeTable = (_a = {}, | ||
_a[58 /* Colon */] = '%3A', | ||
_a[47 /* Slash */] = '%2F', | ||
_a[63 /* QuestionMark */] = '%3F', | ||
_a[35 /* Hash */] = '%23', | ||
_a[91 /* OpenSquareBracket */] = '%5B', | ||
_a[93 /* CloseSquareBracket */] = '%5D', | ||
_a[64 /* AtSign */] = '%40', | ||
_a[33 /* ExclamationMark */] = '%21', | ||
_a[36 /* DollarSign */] = '%24', | ||
_a[38 /* Ampersand */] = '%26', | ||
_a[39 /* SingleQuote */] = '%27', | ||
_a[40 /* OpenParen */] = '%28', | ||
_a[41 /* CloseParen */] = '%29', | ||
_a[42 /* Asterisk */] = '%2A', | ||
_a[43 /* Plus */] = '%2B', | ||
_a[44 /* Comma */] = '%2C', | ||
_a[59 /* Semicolon */] = '%3B', | ||
_a[61 /* Equals */] = '%3D', | ||
_a[32 /* Space */] = '%20', | ||
_a); | ||
function encodeURIComponentFast(uriComponent, allowSlash) { | ||
var res = undefined; | ||
var nativeEncodePos = -1; | ||
for (var pos = 0; pos < uriComponent.length; pos++) { | ||
var code = uriComponent.charCodeAt(pos); | ||
// unreserved characters: https://tools.ietf.org/html/rfc3986#section-2.3 | ||
if ((code >= 97 /* a */ && code <= 122 /* z */) | ||
|| (code >= 65 /* A */ && code <= 90 /* Z */) | ||
|| (code >= 48 /* Digit0 */ && code <= 57 /* Digit9 */) | ||
|| code === 45 /* Dash */ | ||
|| code === 46 /* Period */ | ||
|| code === 95 /* Underline */ | ||
|| code === 126 /* Tilde */ | ||
|| (allowSlash && code === 47 /* Slash */)) { | ||
// check if we are delaying native encode | ||
if (nativeEncodePos !== -1) { | ||
res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos)); | ||
nativeEncodePos = -1; | ||
} | ||
// check if we write into a new string (by default we try to return the param) | ||
if (res !== undefined) { | ||
res += uriComponent.charAt(pos); | ||
} | ||
} | ||
else { | ||
// encoding needed, we need to allocate a new string | ||
if (res === undefined) { | ||
res = uriComponent.substr(0, pos); | ||
} | ||
// check with default table first | ||
var escaped = encodeTable[code]; | ||
if (escaped !== undefined) { | ||
// check if we are delaying native encode | ||
if (nativeEncodePos !== -1) { | ||
res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos)); | ||
nativeEncodePos = -1; | ||
} | ||
// append escaped variant to result | ||
res += escaped; | ||
} | ||
else if (nativeEncodePos === -1) { | ||
// use native encode only when needed | ||
nativeEncodePos = pos; | ||
} | ||
} | ||
} | ||
if (nativeEncodePos !== -1) { | ||
res += encodeURIComponent(uriComponent.substring(nativeEncodePos)); | ||
} | ||
return res !== undefined ? res : uriComponent; | ||
} | ||
function encodeURIComponentMinimal(path) { | ||
var res = undefined; | ||
for (var pos = 0; pos < path.length; pos++) { | ||
var code = path.charCodeAt(pos); | ||
if (code === 35 /* Hash */ || code === 63 /* QuestionMark */) { | ||
if (res === undefined) { | ||
res = path.substr(0, pos); | ||
} | ||
res += encodeTable[code]; | ||
} | ||
else { | ||
if (res !== undefined) { | ||
res += path[pos]; | ||
} | ||
} | ||
} | ||
return res !== undefined ? res : path; | ||
} | ||
/** | ||
* Compute `fsPath` for the given uri | ||
*/ | ||
export function uriToFsPath(uri, keepDriveLetterCasing) { | ||
var value; | ||
if (uri.authority && uri.path.length > 1 && uri.scheme === 'file') { | ||
// unc path: file://shares/c$/far/boo | ||
value = "//" + uri.authority + uri.path; | ||
} | ||
else if (uri.path.charCodeAt(0) === 47 /* Slash */ | ||
&& (uri.path.charCodeAt(1) >= 65 /* A */ && uri.path.charCodeAt(1) <= 90 /* Z */ || uri.path.charCodeAt(1) >= 97 /* a */ && uri.path.charCodeAt(1) <= 122 /* z */) | ||
&& uri.path.charCodeAt(2) === 58 /* Colon */) { | ||
if (!keepDriveLetterCasing) { | ||
// windows drive letter: file:///c:/far/boo | ||
value = uri.path[1].toLowerCase() + uri.path.substr(2); | ||
} | ||
else { | ||
value = uri.path.substr(1); | ||
} | ||
} | ||
else { | ||
// other path | ||
value = uri.path; | ||
} | ||
if (isWindows) { | ||
value = value.replace(/\//g, '\\'); | ||
} | ||
return value; | ||
} | ||
/** | ||
* Create the external version of a uri | ||
*/ | ||
function _asFormatted(uri, skipEncoding) { | ||
var encoder = !skipEncoding | ||
? encodeURIComponentFast | ||
: encodeURIComponentMinimal; | ||
var res = ''; | ||
var scheme = uri.scheme, authority = uri.authority, path = uri.path, query = uri.query, fragment = uri.fragment; | ||
if (scheme) { | ||
res += scheme; | ||
res += ':'; | ||
} | ||
if (authority || scheme === 'file') { | ||
res += _slash; | ||
res += _slash; | ||
} | ||
if (authority) { | ||
var idx = authority.indexOf('@'); | ||
if (idx !== -1) { | ||
// <user>@<auth> | ||
var userinfo = authority.substr(0, idx); | ||
authority = authority.substr(idx + 1); | ||
idx = userinfo.indexOf(':'); | ||
if (idx === -1) { | ||
res += encoder(userinfo, false); | ||
} | ||
else { | ||
// <user>:<pass>@<auth> | ||
res += encoder(userinfo.substr(0, idx), false); | ||
res += ':'; | ||
res += encoder(userinfo.substr(idx + 1), false); | ||
} | ||
res += '@'; | ||
} | ||
authority = authority.toLowerCase(); | ||
idx = authority.indexOf(':'); | ||
if (idx === -1) { | ||
res += encoder(authority, false); | ||
} | ||
else { | ||
// <auth>:<port> | ||
res += encoder(authority.substr(0, idx), false); | ||
res += authority.substr(idx); | ||
} | ||
} | ||
if (path) { | ||
// lower-case windows drive letters in /C:/fff or C:/fff | ||
if (path.length >= 3 && path.charCodeAt(0) === 47 /* Slash */ && path.charCodeAt(2) === 58 /* Colon */) { | ||
var code = path.charCodeAt(1); | ||
if (code >= 65 /* A */ && code <= 90 /* Z */) { | ||
path = "/" + String.fromCharCode(code + 32) + ":" + path.substr(3); // "/c:".length === 3 | ||
} | ||
} | ||
else if (path.length >= 2 && path.charCodeAt(1) === 58 /* Colon */) { | ||
var code = path.charCodeAt(0); | ||
if (code >= 65 /* A */ && code <= 90 /* Z */) { | ||
path = String.fromCharCode(code + 32) + ":" + path.substr(2); // "/c:".length === 3 | ||
} | ||
} | ||
// encode the rest of the path | ||
res += encoder(path, true); | ||
} | ||
if (query) { | ||
res += '?'; | ||
res += encoder(query, false); | ||
} | ||
if (fragment) { | ||
res += '#'; | ||
res += !skipEncoding ? encodeURIComponentFast(fragment, false) : fragment; | ||
} | ||
return res; | ||
} | ||
// --- decode | ||
function decodeURIComponentGraceful(str) { | ||
try { | ||
return decodeURIComponent(str); | ||
} | ||
catch (_a) { | ||
if (str.length > 3) { | ||
return str.substr(0, 3) + decodeURIComponentGraceful(str.substr(3)); | ||
} | ||
else { | ||
return str; | ||
} | ||
} | ||
} | ||
var _rEncodedAsHex = /(%[0-9A-Za-z][0-9A-Za-z])+/g; | ||
function percentDecode(str) { | ||
if (!str.match(_rEncodedAsHex)) { | ||
return str; | ||
} | ||
return str.replace(_rEncodedAsHex, function (match) { return decodeURIComponentGraceful(match); }); | ||
} | ||
var LIB=function(t){var r={};function e(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:n})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,r){if(1&r&&(t=e(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var o in t)e.d(n,o,function(r){return t[r]}.bind(null,o));return n},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},e.p="",e(e.s=3)}([function(t,r,e){"use strict";(function(t){var n;if(e.d(r,"a",(function(){return n})),"object"==typeof t)n="win32"===t.platform;else if("object"==typeof navigator){var o=navigator.userAgent;n=o.indexOf("Windows")>=0}}).call(this,e(2))},function(t,r,e){(function(t){function e(t,r){for(var e=0,n=t.length-1;n>=0;n--){var o=t[n];"."===o?t.splice(n,1):".."===o?(t.splice(n,1),e++):e&&(t.splice(n,1),e--)}if(r)for(;e--;e)t.unshift("..");return t}function n(t,r){if(t.filter)return t.filter(r);for(var e=[],n=0;n<t.length;n++)r(t[n],n,t)&&e.push(t[n]);return e}r.resolve=function(){for(var r="",o=!1,i=arguments.length-1;i>=-1&&!o;i--){var a=i>=0?arguments[i]:t.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(r=a+"/"+r,o="/"===a.charAt(0))}return(o?"/":"")+(r=e(n(r.split("/"),(function(t){return!!t})),!o).join("/"))||"."},r.normalize=function(t){var i=r.isAbsolute(t),a="/"===o(t,-1);return(t=e(n(t.split("/"),(function(t){return!!t})),!i).join("/"))||i||(t="."),t&&a&&(t+="/"),(i?"/":"")+t},r.isAbsolute=function(t){return"/"===t.charAt(0)},r.join=function(){var t=Array.prototype.slice.call(arguments,0);return r.normalize(n(t,(function(t,r){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t})).join("/"))},r.relative=function(t,e){function n(t){for(var r=0;r<t.length&&""===t[r];r++);for(var e=t.length-1;e>=0&&""===t[e];e--);return r>e?[]:t.slice(r,e-r+1)}t=r.resolve(t).substr(1),e=r.resolve(e).substr(1);for(var o=n(t.split("/")),i=n(e.split("/")),a=Math.min(o.length,i.length),u=a,s=0;s<a;s++)if(o[s]!==i[s]){u=s;break}var h=[];for(s=u;s<o.length;s++)h.push("..");return(h=h.concat(i.slice(u))).join("/")},r.sep="/",r.delimiter=":",r.dirname=function(t){if("string"!=typeof t&&(t+=""),0===t.length)return".";for(var r=t.charCodeAt(0),e=47===r,n=-1,o=!0,i=t.length-1;i>=1;--i)if(47===(r=t.charCodeAt(i))){if(!o){n=i;break}}else o=!1;return-1===n?e?"/":".":e&&1===n?"/":t.slice(0,n)},r.basename=function(t,r){var e=function(t){"string"!=typeof t&&(t+="");var r,e=0,n=-1,o=!0;for(r=t.length-1;r>=0;--r)if(47===t.charCodeAt(r)){if(!o){e=r+1;break}}else-1===n&&(o=!1,n=r+1);return-1===n?"":t.slice(e,n)}(t);return r&&e.substr(-1*r.length)===r&&(e=e.substr(0,e.length-r.length)),e},r.extname=function(t){"string"!=typeof t&&(t+="");for(var r=-1,e=0,n=-1,o=!0,i=0,a=t.length-1;a>=0;--a){var u=t.charCodeAt(a);if(47!==u)-1===n&&(o=!1,n=a+1),46===u?-1===r?r=a:1!==i&&(i=1):-1!==r&&(i=-1);else if(!o){e=a+1;break}}return-1===r||-1===n||0===i||1===i&&r===n-1&&r===e+1?"":t.slice(r,n)};var o="b"==="ab".substr(-1)?function(t,r,e){return t.substr(r,e)}:function(t,r,e){return r<0&&(r=t.length+r),t.substr(r,e)}}).call(this,e(2))},function(t,r){var e,n,o=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(t){if(e===setTimeout)return setTimeout(t,0);if((e===i||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(r){try{return e.call(null,t,0)}catch(r){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:i}catch(t){e=i}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(t){n=a}}();var s,h=[],f=!1,c=-1;function l(){f&&s&&(f=!1,s.length?h=s.concat(h):c=-1,h.length&&p())}function p(){if(!f){var t=u(l);f=!0;for(var r=h.length;r;){for(s=h,h=[];++c<r;)s&&s[c].run();c=-1,r=h.length}s=null,f=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===a||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{n(t)}catch(r){try{return n.call(null,t)}catch(r){return n.call(this,t)}}}(t)}}function d(t,r){this.fun=t,this.array=r}function m(){}o.nextTick=function(t){var r=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)r[e-1]=arguments[e];h.push(new d(t,r)),1!==h.length||f||u(p)},d.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=m,o.addListener=m,o.once=m,o.off=m,o.removeListener=m,o.removeAllListeners=m,o.emit=m,o.prependListener=m,o.prependOnceListener=m,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(t,r,e){"use strict";e.r(r),e.d(r,"URI",(function(){return l})),e.d(r,"Utils",(function(){return _}));var n,o,i=e(0),a=(n=function(t,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e])})(t,r)},function(t,r){function e(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e)}),u=/^\w[\w\d+.-]*$/,s=/^\//,h=/^\/\//;var f="/",c=/^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,l=function(){function t(t,r,e,n,o,i){void 0===i&&(i=!1),"object"==typeof t?(this.scheme=t.scheme||"",this.authority=t.authority||"",this.path=t.path||"",this.query=t.query||"",this.fragment=t.fragment||""):(this.scheme=function(t,r){return t||r?t:"file"}(t,i),this.authority=r||"",this.path=function(t,r){switch(t){case"https":case"http":case"file":r?r[0]!==f&&(r=f+r):r=f}return r}(this.scheme,e||""),this.query=n||"",this.fragment=o||"",function(t,r){if(!t.scheme&&r)throw new Error('[UriError]: Scheme is missing: {scheme: "", authority: "'+t.authority+'", path: "'+t.path+'", query: "'+t.query+'", fragment: "'+t.fragment+'"}');if(t.scheme&&!u.test(t.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(t.path)if(t.authority){if(!s.test(t.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(h.test(t.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this,i))}return t.isUri=function(r){return r instanceof t||!!r&&("string"==typeof r.authority&&"string"==typeof r.fragment&&"string"==typeof r.path&&"string"==typeof r.query&&"string"==typeof r.scheme&&"function"==typeof r.fsPath&&"function"==typeof r.with&&"function"==typeof r.toString)},Object.defineProperty(t.prototype,"fsPath",{get:function(){return v(this,!1)},enumerable:!1,configurable:!0}),t.prototype.with=function(t){if(!t)return this;var r=t.scheme,e=t.authority,n=t.path,o=t.query,i=t.fragment;return void 0===r?r=this.scheme:null===r&&(r=""),void 0===e?e=this.authority:null===e&&(e=""),void 0===n?n=this.path:null===n&&(n=""),void 0===o?o=this.query:null===o&&(o=""),void 0===i?i=this.fragment:null===i&&(i=""),r===this.scheme&&e===this.authority&&n===this.path&&o===this.query&&i===this.fragment?this:new d(r,e,n,o,i)},t.parse=function(t,r){void 0===r&&(r=!1);var e=c.exec(t);return e?new d(e[2]||"",A(e[4]||""),A(e[5]||""),A(e[7]||""),A(e[9]||""),r):new d("","","","","")},t.file=function(t){var r="";if(i.a&&(t=t.replace(/\\/g,f)),t[0]===f&&t[1]===f){var e=t.indexOf(f,2);-1===e?(r=t.substring(2),t=f):(r=t.substring(2,e),t=t.substring(e)||f)}return new d("file",r,t,"","")},t.from=function(t){return new d(t.scheme,t.authority,t.path,t.query,t.fragment)},t.prototype.toString=function(t){return void 0===t&&(t=!1),b(this,t)},t.prototype.toJSON=function(){return this},t.revive=function(r){if(r){if(r instanceof t)return r;var e=new d(r);return e._formatted=r.external,e._fsPath=r._sep===p?r.fsPath:null,e}return r},t}(),p=i.a?1:void 0,d=function(t){function r(){var r=null!==t&&t.apply(this,arguments)||this;return r._formatted=null,r._fsPath=null,r}return a(r,t),Object.defineProperty(r.prototype,"fsPath",{get:function(){return this._fsPath||(this._fsPath=v(this,!1)),this._fsPath},enumerable:!1,configurable:!0}),r.prototype.toString=function(t){return void 0===t&&(t=!1),t?b(this,!0):(this._formatted||(this._formatted=b(this,!1)),this._formatted)},r.prototype.toJSON=function(){var t={$mid:1};return this._fsPath&&(t.fsPath=this._fsPath,t._sep=p),this._formatted&&(t.external=this._formatted),this.path&&(t.path=this.path),this.scheme&&(t.scheme=this.scheme),this.authority&&(t.authority=this.authority),this.query&&(t.query=this.query),this.fragment&&(t.fragment=this.fragment),t},r}(l),m=((o={})[58]="%3A",o[47]="%2F",o[63]="%3F",o[35]="%23",o[91]="%5B",o[93]="%5D",o[64]="%40",o[33]="%21",o[36]="%24",o[38]="%26",o[39]="%27",o[40]="%28",o[41]="%29",o[42]="%2A",o[43]="%2B",o[44]="%2C",o[59]="%3B",o[61]="%3D",o[32]="%20",o);function g(t,r){for(var e=void 0,n=-1,o=0;o<t.length;o++){var i=t.charCodeAt(o);if(i>=97&&i<=122||i>=65&&i<=90||i>=48&&i<=57||45===i||46===i||95===i||126===i||r&&47===i)-1!==n&&(e+=encodeURIComponent(t.substring(n,o)),n=-1),void 0!==e&&(e+=t.charAt(o));else{void 0===e&&(e=t.substr(0,o));var a=m[i];void 0!==a?(-1!==n&&(e+=encodeURIComponent(t.substring(n,o)),n=-1),e+=a):-1===n&&(n=o)}}return-1!==n&&(e+=encodeURIComponent(t.substring(n))),void 0!==e?e:t}function y(t){for(var r=void 0,e=0;e<t.length;e++){var n=t.charCodeAt(e);35===n||63===n?(void 0===r&&(r=t.substr(0,e)),r+=m[n]):void 0!==r&&(r+=t[e])}return void 0!==r?r:t}function v(t,r){var e;return e=t.authority&&t.path.length>1&&"file"===t.scheme?"//"+t.authority+t.path:47===t.path.charCodeAt(0)&&(t.path.charCodeAt(1)>=65&&t.path.charCodeAt(1)<=90||t.path.charCodeAt(1)>=97&&t.path.charCodeAt(1)<=122)&&58===t.path.charCodeAt(2)?r?t.path.substr(1):t.path[1].toLowerCase()+t.path.substr(2):t.path,i.a&&(e=e.replace(/\//g,"\\")),e}function b(t,r){var e=r?y:g,n="",o=t.scheme,i=t.authority,a=t.path,u=t.query,s=t.fragment;if(o&&(n+=o,n+=":"),(i||"file"===o)&&(n+=f,n+=f),i){var h=i.indexOf("@");if(-1!==h){var c=i.substr(0,h);i=i.substr(h+1),-1===(h=c.indexOf(":"))?n+=e(c,!1):(n+=e(c.substr(0,h),!1),n+=":",n+=e(c.substr(h+1),!1)),n+="@"}-1===(h=(i=i.toLowerCase()).indexOf(":"))?n+=e(i,!1):(n+=e(i.substr(0,h),!1),n+=i.substr(h))}if(a){if(a.length>=3&&47===a.charCodeAt(0)&&58===a.charCodeAt(2))(l=a.charCodeAt(1))>=65&&l<=90&&(a="/"+String.fromCharCode(l+32)+":"+a.substr(3));else if(a.length>=2&&58===a.charCodeAt(1)){var l;(l=a.charCodeAt(0))>=65&&l<=90&&(a=String.fromCharCode(l+32)+":"+a.substr(2))}n+=e(a,!0)}return u&&(n+="?",n+=e(u,!1)),s&&(n+="#",n+=r?s:g(s,!1)),n}var w=/(%[0-9A-Za-z][0-9A-Za-z])+/g;function A(t){return t.match(w)?t.replace(w,(function(t){return function t(r){try{return decodeURIComponent(r)}catch(e){return r.length>3?r.substr(0,3)+t(r.substr(3)):r}}(t)})):t}var _,C=e(1),j=function(){for(var t=0,r=0,e=arguments.length;r<e;r++)t+=arguments[r].length;var n=Array(t),o=0;for(r=0;r<e;r++)for(var i=arguments[r],a=0,u=i.length;a<u;a++,o++)n[o]=i[a];return n},P=C.posix||C;!function(t){t.joinPath=function(t){for(var r=[],e=1;e<arguments.length;e++)r[e-1]=arguments[e];return t.with({path:P.join.apply(P,j([t.path],r))})},t.resolvePath=function(t){for(var r=[],e=1;e<arguments.length;e++)r[e-1]=arguments[e];return t.with({path:P.resolve.apply(P,j([t.path],r))})},t.dirname=function(t){var r=P.dirname(t.path);return 1===r.length&&46===r.charCodeAt(0)?t:t.with({path:r})},t.basename=function(t){return P.basename(t.path)},t.extname=function(t){return P.extname(t.path)}}(_||(_={}))}]);void 0===LIB&&console.error("esm-webpack-plugin: nothing exported!");const _LIB$URI=LIB.URI,_LIB$Utils=LIB.Utils;export{_LIB$URI as URI,_LIB$Utils as Utils}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,145 +0,3 @@ | ||
/** | ||
* Uniform Resource Identifier (URI) http://tools.ietf.org/html/rfc3986. | ||
* This class is a simple parser which creates the basic component parts | ||
* (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation | ||
* and encoding. | ||
* | ||
* ```txt | ||
* foo://example.com:8042/over/there?name=ferret#nose | ||
* \_/ \______________/\_________/ \_________/ \__/ | ||
* | | | | | | ||
* scheme authority path query fragment | ||
* | _____________________|__ | ||
* / \ / \ | ||
* urn:example:animal:ferret:nose | ||
* ``` | ||
*/ | ||
export declare class URI implements UriComponents { | ||
static isUri(thing: any): thing is URI; | ||
/** | ||
* scheme is the 'http' part of 'http://www.msft.com/some/path?query#fragment'. | ||
* The part before the first colon. | ||
*/ | ||
readonly scheme: string; | ||
/** | ||
* authority is the 'www.msft.com' part of 'http://www.msft.com/some/path?query#fragment'. | ||
* The part between the first double slashes and the next slash. | ||
*/ | ||
readonly authority: string; | ||
/** | ||
* path is the '/some/path' part of 'http://www.msft.com/some/path?query#fragment'. | ||
*/ | ||
readonly path: string; | ||
/** | ||
* query is the 'query' part of 'http://www.msft.com/some/path?query#fragment'. | ||
*/ | ||
readonly query: string; | ||
/** | ||
* fragment is the 'fragment' part of 'http://www.msft.com/some/path?query#fragment'. | ||
*/ | ||
readonly fragment: string; | ||
/** | ||
* @internal | ||
*/ | ||
protected constructor(scheme: string, authority?: string, path?: string, query?: string, fragment?: string, _strict?: boolean); | ||
/** | ||
* @internal | ||
*/ | ||
protected constructor(components: UriComponents); | ||
/** | ||
* Returns a string representing the corresponding file system path of this URI. | ||
* Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the | ||
* platform specific path separator. | ||
* | ||
* * Will *not* validate the path for invalid characters and semantics. | ||
* * Will *not* look at the scheme of this URI. | ||
* * The result shall *not* be used for display purposes but for accessing a file on disk. | ||
* | ||
* | ||
* The *difference* to `URI#path` is the use of the platform specific separator and the handling | ||
* of UNC paths. See the below sample of a file-uri with an authority (UNC path). | ||
* | ||
* ```ts | ||
const u = URI.parse('file://server/c$/folder/file.txt') | ||
u.authority === 'server' | ||
u.path === '/shares/c$/file.txt' | ||
u.fsPath === '\\server\c$\folder\file.txt' | ||
``` | ||
* | ||
* Using `URI#path` to read a file (using fs-apis) would not be enough because parts of the path, | ||
* namely the server name, would be missing. Therefore `URI#fsPath` exists - it's sugar to ease working | ||
* with URIs that represent files on disk (`file` scheme). | ||
*/ | ||
readonly fsPath: string; | ||
with(change: { | ||
scheme?: string; | ||
authority?: string | null; | ||
path?: string | null; | ||
query?: string | null; | ||
fragment?: string | null; | ||
}): URI; | ||
/** | ||
* Creates a new URI from a string, e.g. `http://www.msft.com/some/path`, | ||
* `file:///usr/home`, or `scheme:with/path`. | ||
* | ||
* @param value A string which represents an URI (see `URI#toString`). | ||
*/ | ||
static parse(value: string, _strict?: boolean): URI; | ||
/** | ||
* Creates a new URI from a file system path, e.g. `c:\my\files`, | ||
* `/usr/home`, or `\\server\share\some\path`. | ||
* | ||
* The *difference* between `URI#parse` and `URI#file` is that the latter treats the argument | ||
* as path, not as stringified-uri. E.g. `URI.file(path)` is **not the same as** | ||
* `URI.parse('file://' + path)` because the path might contain characters that are | ||
* interpreted (# and ?). See the following sample: | ||
* ```ts | ||
const good = URI.file('/coding/c#/project1'); | ||
good.scheme === 'file'; | ||
good.path === '/coding/c#/project1'; | ||
good.fragment === ''; | ||
const bad = URI.parse('file://' + '/coding/c#/project1'); | ||
bad.scheme === 'file'; | ||
bad.path === '/coding/c'; // path is now broken | ||
bad.fragment === '/project1'; | ||
``` | ||
* | ||
* @param path A file system path (see `URI#fsPath`) | ||
*/ | ||
static file(path: string): URI; | ||
static from(components: { | ||
scheme: string; | ||
authority?: string; | ||
path?: string; | ||
query?: string; | ||
fragment?: string; | ||
}): URI; | ||
/** | ||
* Creates a string representation for this URI. It's guaranteed that calling | ||
* `URI.parse` with the result of this function creates an URI which is equal | ||
* to this URI. | ||
* | ||
* * The result shall *not* be used for display purposes but for externalization or transport. | ||
* * The result will be encoded using the percentage encoding and encoding happens mostly | ||
* ignore the scheme-specific encoding rules. | ||
* | ||
* @param skipEncoding Do not encode the result, default is `false` | ||
*/ | ||
toString(skipEncoding?: boolean): string; | ||
toJSON(): UriComponents; | ||
static revive(data: UriComponents | URI): URI; | ||
static revive(data: UriComponents | URI | undefined): URI | undefined; | ||
static revive(data: UriComponents | URI | null): URI | null; | ||
static revive(data: UriComponents | URI | undefined | null): URI | undefined | null; | ||
} | ||
export interface UriComponents { | ||
scheme: string; | ||
authority: string; | ||
path: string; | ||
query: string; | ||
fragment: string; | ||
} | ||
/** | ||
* Compute `fsPath` for the given uri | ||
*/ | ||
export declare function uriToFsPath(uri: URI, keepDriveLetterCasing: boolean): string; | ||
import { URI } from './uri'; | ||
import { Utils } from './utils'; | ||
export { URI, Utils }; |
@@ -1,655 +0,2 @@ | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
(function (factory) { | ||
if (typeof module === "object" && typeof module.exports === "object") { | ||
var v = factory(require, exports); | ||
if (v !== undefined) module.exports = v; | ||
} | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports"], factory); | ||
} | ||
})(function (require, exports) { | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
'use strict'; | ||
var _a; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var isWindows; | ||
if (typeof process === 'object') { | ||
isWindows = process.platform === 'win32'; | ||
} | ||
else if (typeof navigator === 'object') { | ||
var userAgent = navigator.userAgent; | ||
isWindows = userAgent.indexOf('Windows') >= 0; | ||
} | ||
function isHighSurrogate(charCode) { | ||
return (0xD800 <= charCode && charCode <= 0xDBFF); | ||
} | ||
function isLowSurrogate(charCode) { | ||
return (0xDC00 <= charCode && charCode <= 0xDFFF); | ||
} | ||
function isLowerAsciiHex(code) { | ||
return code >= 97 /* a */ && code <= 102 /* f */; | ||
} | ||
function isLowerAsciiLetter(code) { | ||
return code >= 97 /* a */ && code <= 122 /* z */; | ||
} | ||
function isUpperAsciiLetter(code) { | ||
return code >= 65 /* A */ && code <= 90 /* Z */; | ||
} | ||
function isAsciiLetter(code) { | ||
return isLowerAsciiLetter(code) || isUpperAsciiLetter(code); | ||
} | ||
//#endregion | ||
var _schemePattern = /^\w[\w\d+.-]*$/; | ||
var _singleSlashStart = /^\//; | ||
var _doubleSlashStart = /^\/\//; | ||
function _validateUri(ret, _strict) { | ||
// scheme, must be set | ||
if (!ret.scheme && _strict) { | ||
throw new Error("[UriError]: Scheme is missing: {scheme: \"\", authority: \"" + ret.authority + "\", path: \"" + ret.path + "\", query: \"" + ret.query + "\", fragment: \"" + ret.fragment + "\"}"); | ||
} | ||
// scheme, https://tools.ietf.org/html/rfc3986#section-3.1 | ||
// ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) | ||
if (ret.scheme && !_schemePattern.test(ret.scheme)) { | ||
throw new Error('[UriError]: Scheme contains illegal characters.'); | ||
} | ||
// path, http://tools.ietf.org/html/rfc3986#section-3.3 | ||
// If a URI contains an authority component, then the path component | ||
// must either be empty or begin with a slash ("/") character. If a URI | ||
// does not contain an authority component, then the path cannot begin | ||
// with two slash characters ("//"). | ||
if (ret.path) { | ||
if (ret.authority) { | ||
if (!_singleSlashStart.test(ret.path)) { | ||
throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character'); | ||
} | ||
} | ||
else { | ||
if (_doubleSlashStart.test(ret.path)) { | ||
throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")'); | ||
} | ||
} | ||
} | ||
} | ||
// for a while we allowed uris *without* schemes and this is the migration | ||
// for them, e.g. an uri without scheme and without strict-mode warns and falls | ||
// back to the file-scheme. that should cause the least carnage and still be a | ||
// clear warning | ||
function _schemeFix(scheme, _strict) { | ||
if (!scheme && !_strict) { | ||
return 'file'; | ||
} | ||
return scheme; | ||
} | ||
// implements a bit of https://tools.ietf.org/html/rfc3986#section-5 | ||
function _referenceResolution(scheme, path) { | ||
// the slash-character is our 'default base' as we don't | ||
// support constructing URIs relative to other URIs. This | ||
// also means that we alter and potentially break paths. | ||
// see https://tools.ietf.org/html/rfc3986#section-5.1.4 | ||
switch (scheme) { | ||
case 'https': | ||
case 'http': | ||
case 'file': | ||
if (!path) { | ||
path = _slash; | ||
} | ||
else if (path[0] !== _slash) { | ||
path = _slash + path; | ||
} | ||
break; | ||
} | ||
return path; | ||
} | ||
var _empty = ''; | ||
var _slash = '/'; | ||
var _regexp = /^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/; | ||
/** | ||
* Uniform Resource Identifier (URI) http://tools.ietf.org/html/rfc3986. | ||
* This class is a simple parser which creates the basic component parts | ||
* (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation | ||
* and encoding. | ||
* | ||
* ```txt | ||
* foo://example.com:8042/over/there?name=ferret#nose | ||
* \_/ \______________/\_________/ \_________/ \__/ | ||
* | | | | | | ||
* scheme authority path query fragment | ||
* | _____________________|__ | ||
* / \ / \ | ||
* urn:example:animal:ferret:nose | ||
* ``` | ||
*/ | ||
var URI = /** @class */ (function () { | ||
/** | ||
* @internal | ||
*/ | ||
function URI(schemeOrData, authority, path, query, fragment, _strict) { | ||
if (_strict === void 0) { _strict = false; } | ||
if (typeof schemeOrData === 'object') { | ||
this.scheme = schemeOrData.scheme || _empty; | ||
this.authority = schemeOrData.authority || _empty; | ||
this.path = schemeOrData.path || _empty; | ||
this.query = schemeOrData.query || _empty; | ||
this.fragment = schemeOrData.fragment || _empty; | ||
// no validation because it's this URI | ||
// that creates uri components. | ||
// _validateUri(this); | ||
} | ||
else { | ||
this.scheme = _schemeFix(schemeOrData, _strict); | ||
this.authority = authority || _empty; | ||
this.path = _referenceResolution(this.scheme, path || _empty); | ||
this.query = query || _empty; | ||
this.fragment = fragment || _empty; | ||
_validateUri(this, _strict); | ||
} | ||
} | ||
URI.isUri = function (thing) { | ||
if (thing instanceof URI) { | ||
return true; | ||
} | ||
if (!thing) { | ||
return false; | ||
} | ||
return typeof thing.authority === 'string' | ||
&& typeof thing.fragment === 'string' | ||
&& typeof thing.path === 'string' | ||
&& typeof thing.query === 'string' | ||
&& typeof thing.scheme === 'string' | ||
&& typeof thing.fsPath === 'function' | ||
&& typeof thing.with === 'function' | ||
&& typeof thing.toString === 'function'; | ||
}; | ||
Object.defineProperty(URI.prototype, "fsPath", { | ||
// ---- filesystem path ----------------------- | ||
/** | ||
* Returns a string representing the corresponding file system path of this URI. | ||
* Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the | ||
* platform specific path separator. | ||
* | ||
* * Will *not* validate the path for invalid characters and semantics. | ||
* * Will *not* look at the scheme of this URI. | ||
* * The result shall *not* be used for display purposes but for accessing a file on disk. | ||
* | ||
* | ||
* The *difference* to `URI#path` is the use of the platform specific separator and the handling | ||
* of UNC paths. See the below sample of a file-uri with an authority (UNC path). | ||
* | ||
* ```ts | ||
const u = URI.parse('file://server/c$/folder/file.txt') | ||
u.authority === 'server' | ||
u.path === '/shares/c$/file.txt' | ||
u.fsPath === '\\server\c$\folder\file.txt' | ||
``` | ||
* | ||
* Using `URI#path` to read a file (using fs-apis) would not be enough because parts of the path, | ||
* namely the server name, would be missing. Therefore `URI#fsPath` exists - it's sugar to ease working | ||
* with URIs that represent files on disk (`file` scheme). | ||
*/ | ||
get: function () { | ||
// if (this.scheme !== 'file') { | ||
// console.warn(`[UriError] calling fsPath with scheme ${this.scheme}`); | ||
// } | ||
return uriToFsPath(this, false); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
// ---- modify to new ------------------------- | ||
URI.prototype.with = function (change) { | ||
if (!change) { | ||
return this; | ||
} | ||
var scheme = change.scheme, authority = change.authority, path = change.path, query = change.query, fragment = change.fragment; | ||
if (scheme === undefined) { | ||
scheme = this.scheme; | ||
} | ||
else if (scheme === null) { | ||
scheme = _empty; | ||
} | ||
if (authority === undefined) { | ||
authority = this.authority; | ||
} | ||
else if (authority === null) { | ||
authority = _empty; | ||
} | ||
if (path === undefined) { | ||
path = this.path; | ||
} | ||
else if (path === null) { | ||
path = _empty; | ||
} | ||
if (query === undefined) { | ||
query = this.query; | ||
} | ||
else if (query === null) { | ||
query = _empty; | ||
} | ||
if (fragment === undefined) { | ||
fragment = this.fragment; | ||
} | ||
else if (fragment === null) { | ||
fragment = _empty; | ||
} | ||
if (scheme === this.scheme | ||
&& authority === this.authority | ||
&& path === this.path | ||
&& query === this.query | ||
&& fragment === this.fragment) { | ||
return this; | ||
} | ||
return new _URI(scheme, authority, path, query, fragment); | ||
}; | ||
// ---- parse & validate ------------------------ | ||
/** | ||
* Creates a new URI from a string, e.g. `http://www.msft.com/some/path`, | ||
* `file:///usr/home`, or `scheme:with/path`. | ||
* | ||
* @param value A string which represents an URI (see `URI#toString`). | ||
*/ | ||
URI.parse = function (value, _strict) { | ||
if (_strict === void 0) { _strict = false; } | ||
var match = _regexp.exec(value); | ||
if (!match) { | ||
return new _URI(_empty, _empty, _empty, _empty, _empty); | ||
} | ||
return new _URI(match[2] || _empty, percentDecode(match[4] || _empty), percentDecode(match[5] || _empty), percentDecode(match[7] || _empty), percentDecode(match[9] || _empty), _strict); | ||
}; | ||
/** | ||
* Creates a new URI from a file system path, e.g. `c:\my\files`, | ||
* `/usr/home`, or `\\server\share\some\path`. | ||
* | ||
* The *difference* between `URI#parse` and `URI#file` is that the latter treats the argument | ||
* as path, not as stringified-uri. E.g. `URI.file(path)` is **not the same as** | ||
* `URI.parse('file://' + path)` because the path might contain characters that are | ||
* interpreted (# and ?). See the following sample: | ||
* ```ts | ||
const good = URI.file('/coding/c#/project1'); | ||
good.scheme === 'file'; | ||
good.path === '/coding/c#/project1'; | ||
good.fragment === ''; | ||
const bad = URI.parse('file://' + '/coding/c#/project1'); | ||
bad.scheme === 'file'; | ||
bad.path === '/coding/c'; // path is now broken | ||
bad.fragment === '/project1'; | ||
``` | ||
* | ||
* @param path A file system path (see `URI#fsPath`) | ||
*/ | ||
URI.file = function (path) { | ||
var authority = _empty; | ||
// normalize to fwd-slashes on windows, | ||
// on other systems bwd-slashes are valid | ||
// filename character, eg /f\oo/ba\r.txt | ||
if (isWindows) { | ||
path = path.replace(/\\/g, _slash); | ||
} | ||
// check for authority as used in UNC shares | ||
// or use the path as given | ||
if (path[0] === _slash && path[1] === _slash) { | ||
var idx = path.indexOf(_slash, 2); | ||
if (idx === -1) { | ||
authority = path.substring(2); | ||
path = _slash; | ||
} | ||
else { | ||
authority = path.substring(2, idx); | ||
path = path.substring(idx) || _slash; | ||
} | ||
} | ||
return new _URI('file', authority, path, _empty, _empty); | ||
}; | ||
URI.from = function (components) { | ||
return new _URI(components.scheme, components.authority, components.path, components.query, components.fragment); | ||
}; | ||
// /** | ||
// * Join a URI path with path fragments and normalizes the resulting path. | ||
// * | ||
// * @param uri The input URI. | ||
// * @param pathFragment The path fragment to add to the URI path. | ||
// * @returns The resulting URI. | ||
// */ | ||
// static joinPath(uri: URI, ...pathFragment: string[]): URI { | ||
// if (!uri.path) { | ||
// throw new Error(`[UriError]: cannot call joinPaths on URI without path`); | ||
// } | ||
// let newPath: string; | ||
// if (isWindows && uri.scheme === 'file') { | ||
// newPath = URI.file(paths.win32.join(uriToFsPath(uri, true), ...pathFragment)).path; | ||
// } else { | ||
// newPath = paths.posix.join(uri.path, ...pathFragment); | ||
// } | ||
// return uri.with({ path: newPath }); | ||
// } | ||
// ---- printing/externalize --------------------------- | ||
/** | ||
* Creates a string representation for this URI. It's guaranteed that calling | ||
* `URI.parse` with the result of this function creates an URI which is equal | ||
* to this URI. | ||
* | ||
* * The result shall *not* be used for display purposes but for externalization or transport. | ||
* * The result will be encoded using the percentage encoding and encoding happens mostly | ||
* ignore the scheme-specific encoding rules. | ||
* | ||
* @param skipEncoding Do not encode the result, default is `false` | ||
*/ | ||
URI.prototype.toString = function (skipEncoding) { | ||
if (skipEncoding === void 0) { skipEncoding = false; } | ||
return _asFormatted(this, skipEncoding); | ||
}; | ||
URI.prototype.toJSON = function () { | ||
return this; | ||
}; | ||
URI.revive = function (data) { | ||
if (!data) { | ||
return data; | ||
} | ||
else if (data instanceof URI) { | ||
return data; | ||
} | ||
else { | ||
var result = new _URI(data); | ||
result._formatted = data.external; | ||
result._fsPath = data._sep === _pathSepMarker ? data.fsPath : null; | ||
return result; | ||
} | ||
}; | ||
return URI; | ||
}()); | ||
exports.URI = URI; | ||
var _pathSepMarker = isWindows ? 1 : undefined; | ||
// eslint-disable-next-line @typescript-eslint/class-name-casing | ||
var _URI = /** @class */ (function (_super) { | ||
__extends(_URI, _super); | ||
function _URI() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this._formatted = null; | ||
_this._fsPath = null; | ||
return _this; | ||
} | ||
Object.defineProperty(_URI.prototype, "fsPath", { | ||
get: function () { | ||
if (!this._fsPath) { | ||
this._fsPath = uriToFsPath(this, false); | ||
} | ||
return this._fsPath; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
_URI.prototype.toString = function (skipEncoding) { | ||
if (skipEncoding === void 0) { skipEncoding = false; } | ||
if (!skipEncoding) { | ||
if (!this._formatted) { | ||
this._formatted = _asFormatted(this, false); | ||
} | ||
return this._formatted; | ||
} | ||
else { | ||
// we don't cache that | ||
return _asFormatted(this, true); | ||
} | ||
}; | ||
_URI.prototype.toJSON = function () { | ||
var res = { | ||
$mid: 1 | ||
}; | ||
// cached state | ||
if (this._fsPath) { | ||
res.fsPath = this._fsPath; | ||
res._sep = _pathSepMarker; | ||
} | ||
if (this._formatted) { | ||
res.external = this._formatted; | ||
} | ||
// uri components | ||
if (this.path) { | ||
res.path = this.path; | ||
} | ||
if (this.scheme) { | ||
res.scheme = this.scheme; | ||
} | ||
if (this.authority) { | ||
res.authority = this.authority; | ||
} | ||
if (this.query) { | ||
res.query = this.query; | ||
} | ||
if (this.fragment) { | ||
res.fragment = this.fragment; | ||
} | ||
return res; | ||
}; | ||
return _URI; | ||
}(URI)); | ||
// reserved characters: https://tools.ietf.org/html/rfc3986#section-2.2 | ||
var encodeTable = (_a = {}, | ||
_a[58 /* Colon */] = '%3A', | ||
_a[47 /* Slash */] = '%2F', | ||
_a[63 /* QuestionMark */] = '%3F', | ||
_a[35 /* Hash */] = '%23', | ||
_a[91 /* OpenSquareBracket */] = '%5B', | ||
_a[93 /* CloseSquareBracket */] = '%5D', | ||
_a[64 /* AtSign */] = '%40', | ||
_a[33 /* ExclamationMark */] = '%21', | ||
_a[36 /* DollarSign */] = '%24', | ||
_a[38 /* Ampersand */] = '%26', | ||
_a[39 /* SingleQuote */] = '%27', | ||
_a[40 /* OpenParen */] = '%28', | ||
_a[41 /* CloseParen */] = '%29', | ||
_a[42 /* Asterisk */] = '%2A', | ||
_a[43 /* Plus */] = '%2B', | ||
_a[44 /* Comma */] = '%2C', | ||
_a[59 /* Semicolon */] = '%3B', | ||
_a[61 /* Equals */] = '%3D', | ||
_a[32 /* Space */] = '%20', | ||
_a); | ||
function encodeURIComponentFast(uriComponent, allowSlash) { | ||
var res = undefined; | ||
var nativeEncodePos = -1; | ||
for (var pos = 0; pos < uriComponent.length; pos++) { | ||
var code = uriComponent.charCodeAt(pos); | ||
// unreserved characters: https://tools.ietf.org/html/rfc3986#section-2.3 | ||
if ((code >= 97 /* a */ && code <= 122 /* z */) | ||
|| (code >= 65 /* A */ && code <= 90 /* Z */) | ||
|| (code >= 48 /* Digit0 */ && code <= 57 /* Digit9 */) | ||
|| code === 45 /* Dash */ | ||
|| code === 46 /* Period */ | ||
|| code === 95 /* Underline */ | ||
|| code === 126 /* Tilde */ | ||
|| (allowSlash && code === 47 /* Slash */)) { | ||
// check if we are delaying native encode | ||
if (nativeEncodePos !== -1) { | ||
res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos)); | ||
nativeEncodePos = -1; | ||
} | ||
// check if we write into a new string (by default we try to return the param) | ||
if (res !== undefined) { | ||
res += uriComponent.charAt(pos); | ||
} | ||
} | ||
else { | ||
// encoding needed, we need to allocate a new string | ||
if (res === undefined) { | ||
res = uriComponent.substr(0, pos); | ||
} | ||
// check with default table first | ||
var escaped = encodeTable[code]; | ||
if (escaped !== undefined) { | ||
// check if we are delaying native encode | ||
if (nativeEncodePos !== -1) { | ||
res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos)); | ||
nativeEncodePos = -1; | ||
} | ||
// append escaped variant to result | ||
res += escaped; | ||
} | ||
else if (nativeEncodePos === -1) { | ||
// use native encode only when needed | ||
nativeEncodePos = pos; | ||
} | ||
} | ||
} | ||
if (nativeEncodePos !== -1) { | ||
res += encodeURIComponent(uriComponent.substring(nativeEncodePos)); | ||
} | ||
return res !== undefined ? res : uriComponent; | ||
} | ||
function encodeURIComponentMinimal(path) { | ||
var res = undefined; | ||
for (var pos = 0; pos < path.length; pos++) { | ||
var code = path.charCodeAt(pos); | ||
if (code === 35 /* Hash */ || code === 63 /* QuestionMark */) { | ||
if (res === undefined) { | ||
res = path.substr(0, pos); | ||
} | ||
res += encodeTable[code]; | ||
} | ||
else { | ||
if (res !== undefined) { | ||
res += path[pos]; | ||
} | ||
} | ||
} | ||
return res !== undefined ? res : path; | ||
} | ||
/** | ||
* Compute `fsPath` for the given uri | ||
*/ | ||
function uriToFsPath(uri, keepDriveLetterCasing) { | ||
var value; | ||
if (uri.authority && uri.path.length > 1 && uri.scheme === 'file') { | ||
// unc path: file://shares/c$/far/boo | ||
value = "//" + uri.authority + uri.path; | ||
} | ||
else if (uri.path.charCodeAt(0) === 47 /* Slash */ | ||
&& (uri.path.charCodeAt(1) >= 65 /* A */ && uri.path.charCodeAt(1) <= 90 /* Z */ || uri.path.charCodeAt(1) >= 97 /* a */ && uri.path.charCodeAt(1) <= 122 /* z */) | ||
&& uri.path.charCodeAt(2) === 58 /* Colon */) { | ||
if (!keepDriveLetterCasing) { | ||
// windows drive letter: file:///c:/far/boo | ||
value = uri.path[1].toLowerCase() + uri.path.substr(2); | ||
} | ||
else { | ||
value = uri.path.substr(1); | ||
} | ||
} | ||
else { | ||
// other path | ||
value = uri.path; | ||
} | ||
if (isWindows) { | ||
value = value.replace(/\//g, '\\'); | ||
} | ||
return value; | ||
} | ||
exports.uriToFsPath = uriToFsPath; | ||
/** | ||
* Create the external version of a uri | ||
*/ | ||
function _asFormatted(uri, skipEncoding) { | ||
var encoder = !skipEncoding | ||
? encodeURIComponentFast | ||
: encodeURIComponentMinimal; | ||
var res = ''; | ||
var scheme = uri.scheme, authority = uri.authority, path = uri.path, query = uri.query, fragment = uri.fragment; | ||
if (scheme) { | ||
res += scheme; | ||
res += ':'; | ||
} | ||
if (authority || scheme === 'file') { | ||
res += _slash; | ||
res += _slash; | ||
} | ||
if (authority) { | ||
var idx = authority.indexOf('@'); | ||
if (idx !== -1) { | ||
// <user>@<auth> | ||
var userinfo = authority.substr(0, idx); | ||
authority = authority.substr(idx + 1); | ||
idx = userinfo.indexOf(':'); | ||
if (idx === -1) { | ||
res += encoder(userinfo, false); | ||
} | ||
else { | ||
// <user>:<pass>@<auth> | ||
res += encoder(userinfo.substr(0, idx), false); | ||
res += ':'; | ||
res += encoder(userinfo.substr(idx + 1), false); | ||
} | ||
res += '@'; | ||
} | ||
authority = authority.toLowerCase(); | ||
idx = authority.indexOf(':'); | ||
if (idx === -1) { | ||
res += encoder(authority, false); | ||
} | ||
else { | ||
// <auth>:<port> | ||
res += encoder(authority.substr(0, idx), false); | ||
res += authority.substr(idx); | ||
} | ||
} | ||
if (path) { | ||
// lower-case windows drive letters in /C:/fff or C:/fff | ||
if (path.length >= 3 && path.charCodeAt(0) === 47 /* Slash */ && path.charCodeAt(2) === 58 /* Colon */) { | ||
var code = path.charCodeAt(1); | ||
if (code >= 65 /* A */ && code <= 90 /* Z */) { | ||
path = "/" + String.fromCharCode(code + 32) + ":" + path.substr(3); // "/c:".length === 3 | ||
} | ||
} | ||
else if (path.length >= 2 && path.charCodeAt(1) === 58 /* Colon */) { | ||
var code = path.charCodeAt(0); | ||
if (code >= 65 /* A */ && code <= 90 /* Z */) { | ||
path = String.fromCharCode(code + 32) + ":" + path.substr(2); // "/c:".length === 3 | ||
} | ||
} | ||
// encode the rest of the path | ||
res += encoder(path, true); | ||
} | ||
if (query) { | ||
res += '?'; | ||
res += encoder(query, false); | ||
} | ||
if (fragment) { | ||
res += '#'; | ||
res += !skipEncoding ? encodeURIComponentFast(fragment, false) : fragment; | ||
} | ||
return res; | ||
} | ||
// --- decode | ||
function decodeURIComponentGraceful(str) { | ||
try { | ||
return decodeURIComponent(str); | ||
} | ||
catch (_a) { | ||
if (str.length > 3) { | ||
return str.substr(0, 3) + decodeURIComponentGraceful(str.substr(3)); | ||
} | ||
else { | ||
return str; | ||
} | ||
} | ||
} | ||
var _rEncodedAsHex = /(%[0-9A-Za-z][0-9A-Za-z])+/g; | ||
function percentDecode(str) { | ||
if (!str.match(_rEncodedAsHex)) { | ||
return str; | ||
} | ||
return str.replace(_rEncodedAsHex, function (match) { return decodeURIComponentGraceful(match); }); | ||
} | ||
}); | ||
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(this,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=1)}([function(t,e){var r,n,i=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function u(t){if(r===setTimeout)return setTimeout(t,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(t){r=o}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(t){n=s}}();var a,f=[],h=!1,c=-1;function l(){h&&a&&(h=!1,a.length?f=a.concat(f):c=-1,f.length&&p())}function p(){if(!h){var t=u(l);h=!0;for(var e=f.length;e;){for(a=f,f=[];++c<e;)a&&a[c].run();c=-1,e=f.length}a=null,h=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}function d(t,e){this.fun=t,this.array=e}function v(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];f.push(new d(t,e)),1!==f.length||h||u(p)},d.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=v,i.addListener=v,i.once=v,i.off=v,i.removeListener=v,i.removeAllListeners=v,i.emit=v,i.prependListener=v,i.prependOnceListener=v,i.listeners=function(t){return[]},i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Utils=e.URI=void 0;var n=r(2);Object.defineProperty(e,"URI",{enumerable:!0,get:function(){return n.URI}});var i=r(4);Object.defineProperty(e,"Utils",{enumerable:!0,get:function(){return i.Utils}})},function(t,e,r){"use strict";var n,i,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.uriToFsPath=e.URI=void 0;var s=r(3),u=/^\w[\w\d+.-]*$/,a=/^\//,f=/^\/\//;var h="/",c=/^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,l=function(){function t(t,e,r,n,i,o){void 0===o&&(o=!1),"object"==typeof t?(this.scheme=t.scheme||"",this.authority=t.authority||"",this.path=t.path||"",this.query=t.query||"",this.fragment=t.fragment||""):(this.scheme=function(t,e){return t||e?t:"file"}(t,o),this.authority=e||"",this.path=function(t,e){switch(t){case"https":case"http":case"file":e?e[0]!==h&&(e=h+e):e=h}return e}(this.scheme,r||""),this.query=n||"",this.fragment=i||"",function(t,e){if(!t.scheme&&e)throw new Error('[UriError]: Scheme is missing: {scheme: "", authority: "'+t.authority+'", path: "'+t.path+'", query: "'+t.query+'", fragment: "'+t.fragment+'"}');if(t.scheme&&!u.test(t.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(t.path)if(t.authority){if(!a.test(t.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(f.test(t.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this,o))}return t.isUri=function(e){return e instanceof t||!!e&&("string"==typeof e.authority&&"string"==typeof e.fragment&&"string"==typeof e.path&&"string"==typeof e.query&&"string"==typeof e.scheme&&"function"==typeof e.fsPath&&"function"==typeof e.with&&"function"==typeof e.toString)},Object.defineProperty(t.prototype,"fsPath",{get:function(){return g(this,!1)},enumerable:!1,configurable:!0}),t.prototype.with=function(t){if(!t)return this;var e=t.scheme,r=t.authority,n=t.path,i=t.query,o=t.fragment;return void 0===e?e=this.scheme:null===e&&(e=""),void 0===r?r=this.authority:null===r&&(r=""),void 0===n?n=this.path:null===n&&(n=""),void 0===i?i=this.query:null===i&&(i=""),void 0===o?o=this.fragment:null===o&&(o=""),e===this.scheme&&r===this.authority&&n===this.path&&i===this.query&&o===this.fragment?this:new d(e,r,n,i,o)},t.parse=function(t,e){void 0===e&&(e=!1);var r=c.exec(t);return r?new d(r[2]||"",_(r[4]||""),_(r[5]||""),_(r[7]||""),_(r[9]||""),e):new d("","","","","")},t.file=function(t){var e="";if(s.isWindows&&(t=t.replace(/\\/g,h)),t[0]===h&&t[1]===h){var r=t.indexOf(h,2);-1===r?(e=t.substring(2),t=h):(e=t.substring(2,r),t=t.substring(r)||h)}return new d("file",e,t,"","")},t.from=function(t){return new d(t.scheme,t.authority,t.path,t.query,t.fragment)},t.prototype.toString=function(t){return void 0===t&&(t=!1),b(this,t)},t.prototype.toJSON=function(){return this},t.revive=function(e){if(e){if(e instanceof t)return e;var r=new d(e);return r._formatted=e.external,r._fsPath=e._sep===p?e.fsPath:null,r}return e},t}();e.URI=l;var p=s.isWindows?1:void 0,d=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._formatted=null,e._fsPath=null,e}return o(e,t),Object.defineProperty(e.prototype,"fsPath",{get:function(){return this._fsPath||(this._fsPath=g(this,!1)),this._fsPath},enumerable:!1,configurable:!0}),e.prototype.toString=function(t){return void 0===t&&(t=!1),t?b(this,!0):(this._formatted||(this._formatted=b(this,!1)),this._formatted)},e.prototype.toJSON=function(){var t={$mid:1};return this._fsPath&&(t.fsPath=this._fsPath,t._sep=p),this._formatted&&(t.external=this._formatted),this.path&&(t.path=this.path),this.scheme&&(t.scheme=this.scheme),this.authority&&(t.authority=this.authority),this.query&&(t.query=this.query),this.fragment&&(t.fragment=this.fragment),t},e}(l),v=((i={})[58]="%3A",i[47]="%2F",i[63]="%3F",i[35]="%23",i[91]="%5B",i[93]="%5D",i[64]="%40",i[33]="%21",i[36]="%24",i[38]="%26",i[39]="%27",i[40]="%28",i[41]="%29",i[42]="%2A",i[43]="%2B",i[44]="%2C",i[59]="%3B",i[61]="%3D",i[32]="%20",i);function y(t,e){for(var r=void 0,n=-1,i=0;i<t.length;i++){var o=t.charCodeAt(i);if(o>=97&&o<=122||o>=65&&o<=90||o>=48&&o<=57||45===o||46===o||95===o||126===o||e&&47===o)-1!==n&&(r+=encodeURIComponent(t.substring(n,i)),n=-1),void 0!==r&&(r+=t.charAt(i));else{void 0===r&&(r=t.substr(0,i));var s=v[o];void 0!==s?(-1!==n&&(r+=encodeURIComponent(t.substring(n,i)),n=-1),r+=s):-1===n&&(n=i)}}return-1!==n&&(r+=encodeURIComponent(t.substring(n))),void 0!==r?r:t}function m(t){for(var e=void 0,r=0;r<t.length;r++){var n=t.charCodeAt(r);35===n||63===n?(void 0===e&&(e=t.substr(0,r)),e+=v[n]):void 0!==e&&(e+=t[r])}return void 0!==e?e:t}function g(t,e){var r;return r=t.authority&&t.path.length>1&&"file"===t.scheme?"//"+t.authority+t.path:47===t.path.charCodeAt(0)&&(t.path.charCodeAt(1)>=65&&t.path.charCodeAt(1)<=90||t.path.charCodeAt(1)>=97&&t.path.charCodeAt(1)<=122)&&58===t.path.charCodeAt(2)?e?t.path.substr(1):t.path[1].toLowerCase()+t.path.substr(2):t.path,s.isWindows&&(r=r.replace(/\//g,"\\")),r}function b(t,e){var r=e?m:y,n="",i=t.scheme,o=t.authority,s=t.path,u=t.query,a=t.fragment;if(i&&(n+=i,n+=":"),(o||"file"===i)&&(n+=h,n+=h),o){var f=o.indexOf("@");if(-1!==f){var c=o.substr(0,f);o=o.substr(f+1),-1===(f=c.indexOf(":"))?n+=r(c,!1):(n+=r(c.substr(0,f),!1),n+=":",n+=r(c.substr(f+1),!1)),n+="@"}-1===(f=(o=o.toLowerCase()).indexOf(":"))?n+=r(o,!1):(n+=r(o.substr(0,f),!1),n+=o.substr(f))}if(s){if(s.length>=3&&47===s.charCodeAt(0)&&58===s.charCodeAt(2))(l=s.charCodeAt(1))>=65&&l<=90&&(s="/"+String.fromCharCode(l+32)+":"+s.substr(3));else if(s.length>=2&&58===s.charCodeAt(1)){var l;(l=s.charCodeAt(0))>=65&&l<=90&&(s=String.fromCharCode(l+32)+":"+s.substr(2))}n+=r(s,!0)}return u&&(n+="?",n+=r(u,!1)),a&&(n+="#",n+=e?a:y(a,!1)),n}e.uriToFsPath=g;var w=/(%[0-9A-Za-z][0-9A-Za-z])+/g;function _(t){return t.match(w)?t.replace(w,(function(t){return function t(e){try{return decodeURIComponent(e)}catch(r){return e.length>3?e.substr(0,3)+t(e.substr(3)):e}}(t)})):t}},function(t,e,r){"use strict";(function(t){if(Object.defineProperty(e,"__esModule",{value:!0}),e.isWindows=void 0,"object"==typeof t)e.isWindows="win32"===t.platform;else if("object"==typeof navigator){var r=navigator.userAgent;e.isWindows=r.indexOf("Windows")>=0}}).call(this,r(0))},function(t,e,r){"use strict";var n=this&&this.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var n=Array(t),i=0;for(e=0;e<r;e++)for(var o=arguments[e],s=0,u=o.length;s<u;s++,i++)n[i]=o[s];return n};Object.defineProperty(e,"__esModule",{value:!0}),e.Utils=void 0;var i=r(5),o=i.posix||i;!function(t){t.joinPath=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return t.with({path:o.join.apply(o,n([t.path],e))})},t.resolvePath=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return t.with({path:o.resolve.apply(o,n([t.path],e))})},t.dirname=function(t){var e=o.dirname(t.path);return 1===e.length&&46===e.charCodeAt(0)?t:t.with({path:e})},t.basename=function(t){return o.basename(t.path)},t.extname=function(t){return o.extname(t.path)}}(e.Utils||(e.Utils={}))},function(t,e,r){(function(t){function r(t,e){for(var r=0,n=t.length-1;n>=0;n--){var i=t[n];"."===i?t.splice(n,1):".."===i?(t.splice(n,1),r++):r&&(t.splice(n,1),r--)}if(e)for(;r--;r)t.unshift("..");return t}function n(t,e){if(t.filter)return t.filter(e);for(var r=[],n=0;n<t.length;n++)e(t[n],n,t)&&r.push(t[n]);return r}e.resolve=function(){for(var e="",i=!1,o=arguments.length-1;o>=-1&&!i;o--){var s=o>=0?arguments[o]:t.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(e=s+"/"+e,i="/"===s.charAt(0))}return(i?"/":"")+(e=r(n(e.split("/"),(function(t){return!!t})),!i).join("/"))||"."},e.normalize=function(t){var o=e.isAbsolute(t),s="/"===i(t,-1);return(t=r(n(t.split("/"),(function(t){return!!t})),!o).join("/"))||o||(t="."),t&&s&&(t+="/"),(o?"/":"")+t},e.isAbsolute=function(t){return"/"===t.charAt(0)},e.join=function(){var t=Array.prototype.slice.call(arguments,0);return e.normalize(n(t,(function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t})).join("/"))},e.relative=function(t,r){function n(t){for(var e=0;e<t.length&&""===t[e];e++);for(var r=t.length-1;r>=0&&""===t[r];r--);return e>r?[]:t.slice(e,r-e+1)}t=e.resolve(t).substr(1),r=e.resolve(r).substr(1);for(var i=n(t.split("/")),o=n(r.split("/")),s=Math.min(i.length,o.length),u=s,a=0;a<s;a++)if(i[a]!==o[a]){u=a;break}var f=[];for(a=u;a<i.length;a++)f.push("..");return(f=f.concat(o.slice(u))).join("/")},e.sep="/",e.delimiter=":",e.dirname=function(t){if("string"!=typeof t&&(t+=""),0===t.length)return".";for(var e=t.charCodeAt(0),r=47===e,n=-1,i=!0,o=t.length-1;o>=1;--o)if(47===(e=t.charCodeAt(o))){if(!i){n=o;break}}else i=!1;return-1===n?r?"/":".":r&&1===n?"/":t.slice(0,n)},e.basename=function(t,e){var r=function(t){"string"!=typeof t&&(t+="");var e,r=0,n=-1,i=!0;for(e=t.length-1;e>=0;--e)if(47===t.charCodeAt(e)){if(!i){r=e+1;break}}else-1===n&&(i=!1,n=e+1);return-1===n?"":t.slice(r,n)}(t);return e&&r.substr(-1*e.length)===e&&(r=r.substr(0,r.length-e.length)),r},e.extname=function(t){"string"!=typeof t&&(t+="");for(var e=-1,r=0,n=-1,i=!0,o=0,s=t.length-1;s>=0;--s){var u=t.charCodeAt(s);if(47!==u)-1===n&&(i=!1,n=s+1),46===u?-1===e?e=s:1!==o&&(o=1):-1!==e&&(o=-1);else if(!i){r=s+1;break}}return-1===e||-1===n||0===o||1===o&&e===n-1&&e===r+1?"":t.slice(e,n)};var i="b"==="ab".substr(-1)?function(t,e,r){return t.substr(e,r)}:function(t,e,r){return e<0&&(e=t.length+e),t.substr(e,r)}}).call(this,r(0))}])})); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "vscode-uri", | ||
"author": "Microsoft", | ||
"version": "2.1.2", | ||
"version": "3.0.0", | ||
"description": "The URI implementation that is used by VS Code and its extensions", | ||
@@ -9,18 +9,30 @@ "main": "./lib/umd/index.js", | ||
"module": "./lib/esm/index.js", | ||
"sideEffects": false, | ||
"scripts": { | ||
"compile": "tsc -p ./src && tsc -p ./src/tsconfig.esm.json", | ||
"prepublish": "npm run compile" | ||
"clean": "rimraf lib", | ||
"pack-production": "webpack --mode=production", | ||
"pack-dev": "webpack", | ||
"prepublish": "npm run test && npm run clean && npm run pack-production", | ||
"test": "tsc -p ./src && npm run pack-dev && mocha" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Microsoft/vscode-uri.git" | ||
"url": "git+https://github.com/microsoft/vscode-uri.git" | ||
}, | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/Microsoft/vscode-uri/issues" | ||
"url": "https://github.com/microsoft/vscode-uri/issues" | ||
}, | ||
"homepage": "https://github.com/Microsoft/vscode-uri#readme", | ||
"homepage": "https://github.com/microsoft/vscode-uri#readme", | ||
"devDependencies": { | ||
"typescript": "^3.6.4" | ||
"@purtuga/esm-webpack-plugin": "^1.4.0", | ||
"@types/mocha": "^8.0.3", | ||
"@types/node": "^10.12.21", | ||
"mocha": "8.1.3", | ||
"rimraf": "^3.0.2", | ||
"ts-loader": "^8.0.4", | ||
"typescript": "^4.0.3", | ||
"webpack": "^4.44.2", | ||
"webpack-cli": "^3.3.12" | ||
} | ||
} |
@@ -50,3 +50,3 @@ ## vscode-uri | ||
The source of this module is taken straight from the [vscode](https://github.com/Microsoft/vscode)-sources and because of that issues and pull request should be created in that repository. Thanks and Happy Coding! | ||
The source of this module is taken straight from the [vscode](https://github.com/microsoft/vscode)-sources and because of that issues and pull request should be created in that repository. Thanks and Happy Coding! | ||
@@ -53,0 +53,0 @@ ## Code of Conduct |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
172710
12
9
720
1