fix(ext/url): throw TypeError for empty argument (#18896)

Fixes #18893
This commit is contained in:
Kenta Moriuchi 2023-04-30 19:24:34 +09:00 committed by GitHub
parent 59825a95b4
commit 74bb09aa38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View file

@ -32,6 +32,21 @@ Deno.test(function urlParsing() {
);
});
Deno.test(function emptyUrl() {
assertThrows(
// @ts-ignore for test
() => new URL(),
TypeError,
"1 argument required, but only 0 present",
);
assertThrows(
// @ts-ignore for test
() => URL.canParse(),
TypeError,
"1 argument required, but only 0 present",
);
});
Deno.test(function urlProtocolParsing() {
assertEquals(new URL("Aa+-.1://foo").protocol, "aa+-.1:");
assertEquals(new URL("aA+-.1://foo").protocol, "aa+-.1:");