mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-31 05:39:55 +00:00
48 lines
1.6 KiB
HTML
48 lines
1.6 KiB
HTML
<script src="../include.js"></script>
|
|
<script>
|
|
test(() => {
|
|
function printURL(url) {
|
|
println(`protocol => '${url.protocol}'`);
|
|
println(`username => '${url.username}'`);
|
|
println(`password => '${url.password}'`);
|
|
println(`host => '${url.host}'`);
|
|
println(`hostname => '${url.hostname}'`);
|
|
println(`port => '${url.port}'`);
|
|
println(`pathname => '${url.pathname}'`);
|
|
println(`search => '${url.search}'`);
|
|
println(`hash => '${url.hash}'`);
|
|
}
|
|
|
|
const urls = [
|
|
{ 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' },
|
|
{ input: '/hello', base: 'file://friends/' },
|
|
{ input: '//d:/..', base: 'file:///C:/a/b' },
|
|
];
|
|
|
|
for (url of urls) {
|
|
if (url.base === undefined)
|
|
println(`new URL('${url.input}', ${url.base})`);
|
|
else
|
|
println(`new URL('${url.input}', '${url.base}')`);
|
|
|
|
printURL(new URL(url.input, url.base));
|
|
}
|
|
|
|
println('=========================================');
|
|
|
|
for (url of urls) {
|
|
if (url.base === undefined)
|
|
println(`URL.parse('${url.input}', ${url.base})`);
|
|
else
|
|
println(`URL.parse('${url.input}', '${url.base}')`);
|
|
|
|
printURL(URL.parse(url.input, url.base));
|
|
}
|
|
});
|
|
</script>
|