mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 10:07:15 +02:00
LibWeb/Tests: Support URL tests with an input base
This commit is contained in:
committed by
Andreas Kling
parent
ef27750982
commit
791ad12031
Notes:
sideshowbarker
2024-07-16 20:05:14 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/791ad12031 Pull-request: https://github.com/SerenityOS/serenity/pull/21119 Reviewed-by: https://github.com/kemzeb
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user