mirror of
https://github.com/denoland/deno.git
synced 2025-07-30 08:34:35 +00:00
feat(std/path): Add fromFileUrl() (#4993)
Fix: URL constructor accepts a URL object which is not a base
This commit is contained in:
parent
3e6ea62841
commit
b51c863550
6 changed files with 74 additions and 11 deletions
2
cli/js/lib.deno.shared_globals.d.ts
vendored
2
cli/js/lib.deno.shared_globals.d.ts
vendored
|
@ -1092,7 +1092,7 @@ interface URL {
|
|||
|
||||
declare const URL: {
|
||||
prototype: URL;
|
||||
new (url: string, base?: string | URL): URL;
|
||||
new (url: string | URL, base?: string | URL): URL;
|
||||
createObjectURL(object: any): string;
|
||||
revokeObjectURL(url: string): void;
|
||||
};
|
||||
|
|
|
@ -356,7 +356,7 @@ export class URLImpl implements URL {
|
|||
return this.#searchParams;
|
||||
}
|
||||
|
||||
constructor(url: string, base?: string | URL) {
|
||||
constructor(url: string | URL, base?: string | URL) {
|
||||
let baseParts: URLParts | undefined;
|
||||
if (base) {
|
||||
baseParts = typeof base === "string" ? parse(base) : parts.get(base);
|
||||
|
@ -365,7 +365,7 @@ export class URLImpl implements URL {
|
|||
}
|
||||
}
|
||||
|
||||
const urlParts = parse(url);
|
||||
const urlParts = typeof url === "string" ? parse(url) : parts.get(url);
|
||||
if (!urlParts) {
|
||||
throw new TypeError("Invalid URL.");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue