Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/eslint/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js')
-rw-r--r--tools/node_modules/eslint/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js48
1 files changed, 34 insertions, 14 deletions
diff --git a/tools/node_modules/eslint/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js b/tools/node_modules/eslint/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js
index 015f1af3264..9b132d96caf 100644
--- a/tools/node_modules/eslint/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js
+++ b/tools/node_modules/eslint/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js
@@ -15,6 +15,14 @@
* 5. Path, including "/", optional.
*/
const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?/;
+ /**
+ * File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start
+ * with a leading `/`, they can have a domain (but only if they don't start with a Windows drive).
+ *
+ * 1. Host, optional.
+ * 2. Path, which may inclue "/", guaranteed.
+ */
+ const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/]*)?)?(\/?.*)/i;
function isAbsoluteUrl(input) {
return schemeRegex.test(input);
}
@@ -24,14 +32,25 @@
function isAbsolutePath(input) {
return input.startsWith('/');
}
+ function isFileUrl(input) {
+ return input.startsWith('file:');
+ }
function parseAbsoluteUrl(input) {
const match = urlRegex.exec(input);
+ return makeUrl(match[1], match[2] || '', match[3], match[4] || '', match[5] || '/');
+ }
+ function parseFileUrl(input) {
+ const match = fileRegex.exec(input);
+ const path = match[2];
+ return makeUrl('file:', '', match[1] || '', '', isAbsolutePath(path) ? path : '/' + path);
+ }
+ function makeUrl(scheme, user, host, port, path) {
return {
- scheme: match[1],
- user: match[2] || '',
- host: match[3],
- port: match[4] || '',
- path: match[5] || '/',
+ scheme,
+ user,
+ host,
+ port,
+ path,
relativePath: false,
};
}
@@ -47,14 +66,15 @@
url.host = '';
return url;
}
- if (!isAbsoluteUrl(input)) {
- const url = parseAbsoluteUrl('http://foo.com/' + input);
- url.scheme = '';
- url.host = '';
- url.relativePath = true;
- return url;
- }
- return parseAbsoluteUrl(input);
+ if (isFileUrl(input))
+ return parseFileUrl(input);
+ if (isAbsoluteUrl(input))
+ return parseAbsoluteUrl(input);
+ const url = parseAbsoluteUrl('http://foo.com/' + input);
+ url.scheme = '';
+ url.host = '';
+ url.relativePath = true;
+ return url;
}
function stripPathFilename(path) {
// If a path ends with a parent directory "..", then it's a relative path with excess parent
@@ -151,7 +171,7 @@
const baseUrl = parseUrl(base);
url.scheme = baseUrl.scheme;
// If there's no host, then we were just a path.
- if (!url.host || baseUrl.scheme === 'file:') {
+ if (!url.host) {
// The host, user, and port are joined, you can't copy one without the others.
url.user = baseUrl.user;
url.host = baseUrl.host;