mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Make ServoUrl::as_url return a &Url
This commit is contained in:
parent
fb2c9e7bf5
commit
bba0be13dd
7 changed files with 19 additions and 19 deletions
|
@ -48,7 +48,7 @@ impl URL {
|
|||
}
|
||||
|
||||
pub fn query_pairs(&self) -> Vec<(String, String)> {
|
||||
self.url.borrow().as_url().unwrap().query_pairs().into_owned().collect()
|
||||
self.url.borrow().as_url().query_pairs().into_owned().collect()
|
||||
}
|
||||
|
||||
pub fn set_query_pairs(&self, pairs: &[(String, String)]) {
|
||||
|
|
|
@ -12,37 +12,37 @@ pub struct UrlHelper;
|
|||
|
||||
impl UrlHelper {
|
||||
pub fn Origin(url: &ServoUrl) -> USVString {
|
||||
USVString(quirks::origin(url.as_url().unwrap()).to_owned())
|
||||
USVString(quirks::origin(url.as_url()).to_owned())
|
||||
}
|
||||
pub fn Href(url: &ServoUrl) -> USVString {
|
||||
USVString(quirks::href(url.as_url().unwrap()).to_owned())
|
||||
USVString(quirks::href(url.as_url()).to_owned())
|
||||
}
|
||||
pub fn Hash(url: &ServoUrl) -> USVString {
|
||||
USVString(quirks::hash(url.as_url().unwrap()).to_owned())
|
||||
USVString(quirks::hash(url.as_url()).to_owned())
|
||||
}
|
||||
pub fn Host(url: &ServoUrl) -> USVString {
|
||||
USVString(quirks::host(url.as_url().unwrap()).to_owned())
|
||||
USVString(quirks::host(url.as_url()).to_owned())
|
||||
}
|
||||
pub fn Port(url: &ServoUrl) -> USVString {
|
||||
USVString(quirks::port(url.as_url().unwrap()).to_owned())
|
||||
USVString(quirks::port(url.as_url()).to_owned())
|
||||
}
|
||||
pub fn Search(url: &ServoUrl) -> USVString {
|
||||
USVString(quirks::search(url.as_url().unwrap()).to_owned())
|
||||
USVString(quirks::search(url.as_url()).to_owned())
|
||||
}
|
||||
pub fn Hostname(url: &ServoUrl) -> USVString {
|
||||
USVString(quirks::hostname(url.as_url().unwrap()).to_owned())
|
||||
USVString(quirks::hostname(url.as_url()).to_owned())
|
||||
}
|
||||
pub fn Password(url: &ServoUrl) -> USVString {
|
||||
USVString(quirks::password(url.as_url().unwrap()).to_owned())
|
||||
USVString(quirks::password(url.as_url()).to_owned())
|
||||
}
|
||||
pub fn Pathname(url: &ServoUrl) -> USVString {
|
||||
USVString(quirks::pathname(url.as_url().unwrap()).to_owned())
|
||||
USVString(quirks::pathname(url.as_url()).to_owned())
|
||||
}
|
||||
pub fn Protocol(url: &ServoUrl) -> USVString {
|
||||
USVString(quirks::protocol(url.as_url().unwrap()).to_owned())
|
||||
USVString(quirks::protocol(url.as_url()).to_owned())
|
||||
}
|
||||
pub fn Username(url: &ServoUrl) -> USVString {
|
||||
USVString(quirks::username(url.as_url().unwrap()).to_owned())
|
||||
USVString(quirks::username(url.as_url()).to_owned())
|
||||
}
|
||||
pub fn SetHash(url: &mut ServoUrl, value: USVString) {
|
||||
if let Some(ref mut url) = url.as_mut_url() {
|
||||
|
|
|
@ -210,7 +210,7 @@ impl WebSocket {
|
|||
let resource_url = try!(ServoUrl::parse(&url).map_err(|_| Error::Syntax));
|
||||
// Although we do this replace and parse operation again in the resource thread,
|
||||
// we try here to be able to immediately throw a syntax error on failure.
|
||||
let _ = try!(parse_url(&replace_hosts(&resource_url).as_url().unwrap()).map_err(|_| Error::Syntax));
|
||||
let _ = try!(parse_url(&replace_hosts(&resource_url).as_url()).map_err(|_| Error::Syntax));
|
||||
// Step 2: Disallow https -> ws connections.
|
||||
|
||||
// Step 3: Potentially block access to some ports.
|
||||
|
|
|
@ -1496,8 +1496,8 @@ impl Window {
|
|||
let referrer_policy = referrer_policy.or(doc.get_referrer_policy());
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#navigating-across-documents
|
||||
if !force_reload && url.as_url().unwrap()[..Position::AfterQuery] ==
|
||||
doc.url().as_url().unwrap()[..Position::AfterQuery] {
|
||||
if !force_reload && url.as_url()[..Position::AfterQuery] ==
|
||||
doc.url().as_url()[..Position::AfterQuery] {
|
||||
// Step 5
|
||||
if let Some(fragment) = url.fragment() {
|
||||
doc.check_and_scroll_fragment(fragment);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue