mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Handle url parse errors in Location#assign more gracefully.
This commit is contained in:
parent
da88e9ad9f
commit
7e179d9245
2 changed files with 9 additions and 4 deletions
|
@ -43,10 +43,9 @@ impl<'a> LocationMethods for &'a Location {
|
||||||
// TODO: per spec, we should use the _API base URL_ specified by the
|
// TODO: per spec, we should use the _API base URL_ specified by the
|
||||||
// _entry settings object_.
|
// _entry settings object_.
|
||||||
let base_url = window.get_url();
|
let base_url = window.get_url();
|
||||||
let url = UrlParser::new().base_url(&base_url).parse(&url);
|
if let Ok(url) = UrlParser::new().base_url(&base_url).parse(&url) {
|
||||||
// FIXME: handle URL parse errors more gracefully.
|
window.load_url(url);
|
||||||
let url = url.unwrap();
|
}
|
||||||
window.load_url(url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-hash
|
// https://url.spec.whatwg.org/#dom-urlutils-hash
|
||||||
|
|
|
@ -15,6 +15,12 @@
|
||||||
assert_equals((href + "#x"), location.href, "location href");
|
assert_equals((href + "#x"), location.href, "location href");
|
||||||
|
|
||||||
}, "location assign");
|
}, "location assign");
|
||||||
|
|
||||||
|
test(function () {
|
||||||
|
var href = location.href;
|
||||||
|
location.assign("http://:");
|
||||||
|
assert_equals(location.href, href);
|
||||||
|
}, "URL that fails to parse");
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue