aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/urlhelper.rs
diff options
context:
space:
mode:
authoryodalee <lc85301@gmail.com>2015-03-27 22:42:56 +0800
committeryodalee <lc85301@gmail.com>2015-04-04 20:08:13 +0800
commit77f3b25e65d1c98271332d9606fd10d21a1bba63 (patch)
tree276a7e5b02f5e89f5a61118863e9ebb6b84f30f4 /components/script/dom/urlhelper.rs
parentdb104b738e1ff6b69c3983be6f50f8d7a048b182 (diff)
downloadservo-77f3b25e65d1c98271332d9606fd10d21a1bba63.tar.gz
servo-77f3b25e65d1c98271332d9606fd10d21a1bba63.zip
add readonly pathname function in location
pathname function implemented in UrlHelper 'url is null' check is skip for now
Diffstat (limited to 'components/script/dom/urlhelper.rs')
-rw-r--r--components/script/dom/urlhelper.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/components/script/dom/urlhelper.rs b/components/script/dom/urlhelper.rs
index c83e65c98b2..3b53746bd85 100644
--- a/components/script/dom/urlhelper.rs
+++ b/components/script/dom/urlhelper.rs
@@ -4,7 +4,7 @@
use dom::bindings::str::USVString;
-use url::Url;
+use url::{Url, SchemeData};
use std::borrow::ToOwned;
@@ -31,6 +31,15 @@ impl UrlHelper {
})
}
+ pub fn Pathname(url: &Url) -> USVString {
+ // https://url.spec.whatwg.org/#dom-urlutils-pathname
+ // FIXME: Url null check is skipped for now
+ USVString(match url.scheme_data {
+ SchemeData::NonRelative(ref scheme_data) => scheme_data.clone(),
+ SchemeData::Relative(..) => url.serialize_path().unwrap()
+ })
+ }
+
/// https://html.spec.whatwg.org/multipage/browsers.html#same-origin
pub fn SameOrigin(urlA: &Url, urlB: &Url) -> bool {
if urlA.host() != urlB.host() {