From 5c43131be1a36671fd564b82709e11dff66488f3 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 6 Jul 2020 17:39:13 -0400 Subject: [PATCH] Fix definition of URL constructor (#6653) --- cli/js/lib.deno.shared_globals.d.ts | 2 +- std/path/posix.ts | 2 +- std/path/win32.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/js/lib.deno.shared_globals.d.ts b/cli/js/lib.deno.shared_globals.d.ts index 7bb987ef4f..0c32bd0ed8 100644 --- a/cli/js/lib.deno.shared_globals.d.ts +++ b/cli/js/lib.deno.shared_globals.d.ts @@ -1236,7 +1236,7 @@ interface URL { declare const URL: { prototype: URL; - new (url: string | URL, base?: string | URL): URL; + new (url: string, base?: string | URL): URL; createObjectURL(object: any): string; revokeObjectURL(url: string): void; }; diff --git a/std/path/posix.ts b/std/path/posix.ts index 365232e336..1e78d1cfe9 100644 --- a/std/path/posix.ts +++ b/std/path/posix.ts @@ -435,5 +435,5 @@ export function parse(path: string): ParsedPath { * are ignored. */ export function fromFileUrl(url: string | URL): string { - return new URL(url).pathname; + return new URL(String(url)).pathname; } diff --git a/std/path/win32.ts b/std/path/win32.ts index 8e438a79c3..bac43a61a9 100644 --- a/std/path/win32.ts +++ b/std/path/win32.ts @@ -914,7 +914,7 @@ export function parse(path: string): ParsedPath { * are ignored. */ export function fromFileUrl(url: string | URL): string { - return new URL(url).pathname + return new URL(String(url)).pathname .replace(/^\/*([A-Za-z]:)(\/|$)/, "$1/") .replace(/\//g, "\\"); }