mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
add readonly pathname function in location
pathname function implemented in UrlHelper 'url is null' check is skip for now
This commit is contained in:
parent
db104b738e
commit
77f3b25e65
3 changed files with 15 additions and 1 deletions
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue