Add url encoding option to URL.resolve

Given:

a.href = "over 9000!"

Then:

a.href === BASE_URL + '/over%209000!';

This commits adds an escape: bool option to URL.resolve which will escape the
path, query and fragment when true.

Also changes the Anchor, Image, Link and IFrame getSrc to escape. Escaping is
also used when navigating a frame.
This commit is contained in:
Karl Seguin
2026-02-25 08:17:05 +08:00
parent ca2df83928
commit fcb3f08bcb
13 changed files with 338 additions and 20 deletions

View File

@@ -245,3 +245,11 @@
testing.expectEqual('', b.toString());
}
</script>
<script id=url_encode>
{
let a = document.createElement('a');
a.href = 'over 9000!';
testing.expectEqual(testing.BASE_URL + 'element/html/over%209000!', a.href);
}
</script>