1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:17:34 +00:00

LibWeb/Tests: Support URL tests with an input base

This commit is contained in:
Shannon Booth 2023-09-17 13:41:14 +12:00 committed by Andreas Kling
parent ef27750982
commit 791ad12031
2 changed files with 20 additions and 16 deletions

View file

@ -1,9 +1,13 @@
<script src="../include.js"></script>
<script>
test(() => {
function printURL(input) {
println(input);
const url = new URL(input);
function printURL(input, base) {
if (base === undefined)
println(`new URL('${input}', ${base})`);
else
println(`new URL('${input}', '${base}')`);
const url = new URL(input, base);
println(`protocol => '${url.protocol}'`);
println(`username => '${url.username}'`);
println(`password => '${url.password}'`);
@ -16,14 +20,14 @@
}
for (url of [
'ftp://serenityos.org:21',
'http://[0:1:0:1:0:1:0:1]',
'http://[1:0:1:0:1:0:1:0]',
'http://[1:1:0:0:1:0:0:0]/',
'unknown://serenityos.org:0',
'http://serenityos.org/cat?dog#meow"woof',
{ input: 'ftp://serenityos.org:21' },
{ input: 'http://[0:1:0:1:0:1:0:1]' },
{ input: 'http://[1:0:1:0:1:0:1:0]' },
{ input: 'http://[1:1:0:0:1:0:0:0]/' },
{ input: 'unknown://serenityos.org:0' },
{ input: 'http://serenityos.org/cat?dog#meow"woof' },
]) {
printURL(url);
printURL(url.input, url.base);
}
});
</script>