From 1500547afa9c7784967f1915398bc4e1b3a18e08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Lenksj=C3=B6?= Date: Mon, 4 May 2020 16:06:47 +0200 Subject: fix: URL constructor throws confusing error on invalid scheme (#5057) --- cli/js/web/url.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cli/js/web') diff --git a/cli/js/web/url.ts b/cli/js/web/url.ts index 1ae24ff87..cdbba36d9 100644 --- a/cli/js/web/url.ts +++ b/cli/js/web/url.ts @@ -370,7 +370,7 @@ export class URLImpl implements URL { throw new TypeError("Invalid URL."); } - const { port } = (urlParts.protocol ? urlParts : baseParts) as URLParts; + const { port } = !urlParts.protocol && baseParts ? baseParts : urlParts; if (this.#validatePort(port) === undefined) { throw new TypeError("Invalid URL."); } @@ -389,7 +389,7 @@ export class URLImpl implements URL { hash: urlParts.hash, }); } else { - throw new TypeError("URL requires a base URL."); + throw new TypeError("Invalid URL."); } this.#updateSearchParams(); -- cgit v1.2.3