mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Push the url parsing out of Window::load_url.
This will allow the two callers to decide on the base url independently.
This commit is contained in:
parent
ec9f79067d
commit
40b5c4586e
3 changed files with 18 additions and 12 deletions
|
@ -13,7 +13,7 @@ use dom::window::Window;
|
|||
use dom::window::WindowHelpers;
|
||||
|
||||
use util::str::DOMString;
|
||||
use url::Url;
|
||||
use url::{Url, UrlParser};
|
||||
|
||||
#[dom_struct]
|
||||
pub struct Location {
|
||||
|
@ -39,7 +39,14 @@ impl Location {
|
|||
impl<'a> LocationMethods for &'a Location {
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location-assign
|
||||
fn Assign(self, url: DOMString) {
|
||||
self.window.root().r().load_url(url);
|
||||
let window = self.window.root();
|
||||
// TODO: per spec, we should use the _API base URL_ specified by the
|
||||
// _entry settings object_.
|
||||
let base_url = window.get_url();
|
||||
let url = UrlParser::new().base_url(&base_url).parse(&url);
|
||||
// FIXME: handle URL parse errors more gracefully.
|
||||
let url = url.unwrap();
|
||||
window.load_url(url);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlutils-hash
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue