diff options
author | Gilles Leblanc <gilles.leblanc@gmail.com> | 2014-09-20 08:51:35 -0400 |
---|---|---|
committer | Gilles Leblanc <gilles.leblanc@gmail.com> | 2014-09-20 08:51:35 -0400 |
commit | 652d21796150631f3cbb6c00089415b1f83acc3c (patch) | |
tree | ce1d17e575db42e5d63cb09151afcf8ce5bbd85a /components/script/dom/location.rs | |
parent | de67710934ac89de0cf21911dc57dcda7cb0fae1 (diff) | |
download | servo-652d21796150631f3cbb6c00089415b1f83acc3c.tar.gz servo-652d21796150631f3cbb6c00089415b1f83acc3c.zip |
Share code between Navigator and WorkerNavigator
Also shares code between Location and WorkerLocation. This has been done
by introducing NavigatorInfo and UrlHelper.
Fixes #3159
Diffstat (limited to 'components/script/dom/location.rs')
-rw-r--r-- | components/script/dom/location.rs | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/components/script/dom/location.rs b/components/script/dom/location.rs index 4a435a26b4d..8217c91e4f6 100644 --- a/components/script/dom/location.rs +++ b/components/script/dom/location.rs @@ -7,6 +7,7 @@ use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods; use dom::bindings::global::Window; use dom::bindings::js::{JSRef, Temporary}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; +use dom::urlhelper::UrlHelper; use dom::window::Window; use page::Page; @@ -38,23 +39,15 @@ impl Location { impl<'a> LocationMethods for JSRef<'a, Location> { fn Href(&self) -> DOMString { - self.page.get_url().serialize() + UrlHelper::Href(&self.page.get_url()) } fn Search(&self) -> DOMString { - match self.page.get_url().query { - None => "".to_string(), - Some(ref query) if query.as_slice() == "" => "".to_string(), - Some(ref query) => "?".to_string().append(query.as_slice()) - } + UrlHelper::Search(&self.page.get_url()) } fn Hash(&self) -> DOMString { - match self.page.get_url().fragment { - None => "".to_string(), - Some(ref hash) if hash.as_slice() == "" => "".to_string(), - Some(ref hash) => "#".to_string().append(hash.as_slice()) - } + UrlHelper::Hash(&self.page.get_url()) } } |