mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 15:16:14 +00:00
Doing it is not part of the spec. Whenever needed, the spec will explicitly percent decode the username and password. This fixes some URL WPT tests.
50 lines
1.8 KiB
HTML
50 lines
1.8 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' },
|
|
{ input: 'file://a%C2%ADb/p' },
|
|
{ input: 'http://user%20name:pa%40ss%3Aword@www.ladybird.org' },
|
|
];
|
|
|
|
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>
|