initial commit
This commit is contained in:
127
node_modules/unenv/runtime/node/url/index.cjs
generated
vendored
Normal file
127
node_modules/unenv/runtime/node/url/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.urlToHttpOptions = exports.resolve = exports.pathToFileURL = exports.parse = exports.format = exports.fileURLToPath = exports.domainToUnicode = exports.domainToASCII = exports.default = exports.URLSearchParams = exports.URL = void 0;
|
||||
const URL = globalThis.URL;
|
||||
exports.URL = URL;
|
||||
const URLSearchParams = globalThis.URLSearchParams;
|
||||
exports.URLSearchParams = URLSearchParams;
|
||||
|
||||
const parse = function (urlString, parseQueryString, slashesDenoteHost) {
|
||||
const url = new URL(urlString);
|
||||
|
||||
if (!parseQueryString && !slashesDenoteHost) {
|
||||
return url;
|
||||
}
|
||||
|
||||
throw new Error("parseQueryString and slashesDenoteHost are unsupported");
|
||||
};
|
||||
|
||||
exports.parse = parse;
|
||||
|
||||
const resolve = function (from, to) {
|
||||
const resolvedUrl = new URL(to, new URL(from, "resolve://"));
|
||||
|
||||
if (resolvedUrl.protocol === "resolve:") {
|
||||
const {
|
||||
pathname,
|
||||
search,
|
||||
hash
|
||||
} = resolvedUrl;
|
||||
return pathname + search + hash;
|
||||
}
|
||||
|
||||
return resolvedUrl.toString();
|
||||
};
|
||||
|
||||
exports.resolve = resolve;
|
||||
|
||||
const urlToHttpOptions = function (url) {
|
||||
return {
|
||||
protocol: url.protocol,
|
||||
hostname: url.hostname,
|
||||
hash: url.hash,
|
||||
search: url.search,
|
||||
pathname: url.pathname,
|
||||
path: url.pathname + url.search || "",
|
||||
href: url.href,
|
||||
port: url.port,
|
||||
auth: url.username ? url.username + url.password ? ":" + url.password : "" : ""
|
||||
};
|
||||
};
|
||||
|
||||
exports.urlToHttpOptions = urlToHttpOptions;
|
||||
|
||||
const format = function (urlInput, options) {
|
||||
let url;
|
||||
|
||||
if (typeof urlInput === "string") {
|
||||
url = new URL(urlInput);
|
||||
} else if (!(urlInput instanceof URL)) {
|
||||
throw new TypeError("format urlObject is not supported");
|
||||
} else {
|
||||
url = urlInput;
|
||||
}
|
||||
|
||||
if (options) {
|
||||
if (options.auth === false) {
|
||||
url.username = "";
|
||||
url.password = "";
|
||||
}
|
||||
|
||||
if (options.fragment === false) {
|
||||
url.hash = "";
|
||||
}
|
||||
|
||||
if (options.search === false) {
|
||||
url.search = "";
|
||||
}
|
||||
}
|
||||
|
||||
return url.toString();
|
||||
};
|
||||
|
||||
exports.format = format;
|
||||
|
||||
const domainToASCII = function (domain) {
|
||||
return domain;
|
||||
};
|
||||
|
||||
exports.domainToASCII = domainToASCII;
|
||||
|
||||
const domainToUnicode = function (domain) {
|
||||
return domain;
|
||||
};
|
||||
|
||||
exports.domainToUnicode = domainToUnicode;
|
||||
|
||||
const pathToFileURL = function (path) {
|
||||
return new URL(path);
|
||||
};
|
||||
|
||||
exports.pathToFileURL = pathToFileURL;
|
||||
|
||||
const fileURLToPath = function (url) {
|
||||
if (typeof url === "string") {
|
||||
url = new URL(url);
|
||||
}
|
||||
|
||||
return url.pathname;
|
||||
};
|
||||
|
||||
exports.fileURLToPath = fileURLToPath;
|
||||
var _default = {
|
||||
URL,
|
||||
URLSearchParams,
|
||||
domainToASCII,
|
||||
domainToUnicode,
|
||||
fileURLToPath,
|
||||
format,
|
||||
parse,
|
||||
pathToFileURL,
|
||||
resolve,
|
||||
urlToHttpOptions
|
||||
};
|
||||
module.exports = _default;
|
||||
21
node_modules/unenv/runtime/node/url/index.d.ts
generated
vendored
Normal file
21
node_modules/unenv/runtime/node/url/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
export declare const URL: {
|
||||
new (url: string | URL, base?: string | URL): URL;
|
||||
prototype: URL;
|
||||
createObjectURL(obj: Blob | MediaSource): string;
|
||||
revokeObjectURL(url: string): void;
|
||||
};
|
||||
export declare const URLSearchParams: {
|
||||
new (init?: string | URLSearchParams | Record<string, string> | string[][]): URLSearchParams;
|
||||
prototype: URLSearchParams;
|
||||
toString(): string;
|
||||
};
|
||||
export declare const parse: any;
|
||||
export declare const resolve: any;
|
||||
export declare const urlToHttpOptions: any;
|
||||
export declare const format: any;
|
||||
export declare const domainToASCII: any;
|
||||
export declare const domainToUnicode: any;
|
||||
export declare const pathToFileURL: any;
|
||||
export declare const fileURLToPath: any;
|
||||
declare const _default: any;
|
||||
export default _default;
|
||||
80
node_modules/unenv/runtime/node/url/index.mjs
generated
vendored
Normal file
80
node_modules/unenv/runtime/node/url/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
export const URL = globalThis.URL;
|
||||
export const URLSearchParams = globalThis.URLSearchParams;
|
||||
export const parse = function(urlString, parseQueryString, slashesDenoteHost) {
|
||||
const url = new URL(urlString);
|
||||
if (!parseQueryString && !slashesDenoteHost) {
|
||||
return url;
|
||||
}
|
||||
throw new Error("parseQueryString and slashesDenoteHost are unsupported");
|
||||
};
|
||||
export const resolve = function(from, to) {
|
||||
const resolvedUrl = new URL(to, new URL(from, "resolve://"));
|
||||
if (resolvedUrl.protocol === "resolve:") {
|
||||
const { pathname, search, hash } = resolvedUrl;
|
||||
return pathname + search + hash;
|
||||
}
|
||||
return resolvedUrl.toString();
|
||||
};
|
||||
export const urlToHttpOptions = function(url) {
|
||||
return {
|
||||
protocol: url.protocol,
|
||||
hostname: url.hostname,
|
||||
hash: url.hash,
|
||||
search: url.search,
|
||||
pathname: url.pathname,
|
||||
path: url.pathname + url.search || "",
|
||||
href: url.href,
|
||||
port: url.port,
|
||||
auth: url.username ? url.username + url.password ? ":" + url.password : "" : ""
|
||||
};
|
||||
};
|
||||
export const format = function(urlInput, options) {
|
||||
let url;
|
||||
if (typeof urlInput === "string") {
|
||||
url = new URL(urlInput);
|
||||
} else if (!(urlInput instanceof URL)) {
|
||||
throw new TypeError("format urlObject is not supported");
|
||||
} else {
|
||||
url = urlInput;
|
||||
}
|
||||
if (options) {
|
||||
if (options.auth === false) {
|
||||
url.username = "";
|
||||
url.password = "";
|
||||
}
|
||||
if (options.fragment === false) {
|
||||
url.hash = "";
|
||||
}
|
||||
if (options.search === false) {
|
||||
url.search = "";
|
||||
}
|
||||
}
|
||||
return url.toString();
|
||||
};
|
||||
export const domainToASCII = function(domain) {
|
||||
return domain;
|
||||
};
|
||||
export const domainToUnicode = function(domain) {
|
||||
return domain;
|
||||
};
|
||||
export const pathToFileURL = function(path) {
|
||||
return new URL(path);
|
||||
};
|
||||
export const fileURLToPath = function(url) {
|
||||
if (typeof url === "string") {
|
||||
url = new URL(url);
|
||||
}
|
||||
return url.pathname;
|
||||
};
|
||||
export default {
|
||||
URL,
|
||||
URLSearchParams,
|
||||
domainToASCII,
|
||||
domainToUnicode,
|
||||
fileURLToPath,
|
||||
format,
|
||||
parse,
|
||||
pathToFileURL,
|
||||
resolve,
|
||||
urlToHttpOptions
|
||||
};
|
||||
Reference in New Issue
Block a user