mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +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
|
@ -92,7 +92,7 @@ impl FontTemplateData {
|
|||
.expect("No URL for Core Text font!")
|
||||
.get_string()
|
||||
.to_string()).expect("Couldn't parse Core Text font URL!")
|
||||
.as_url().unwrap().to_file_path()
|
||||
.as_url().to_file_path()
|
||||
.expect("Core Text font didn't name a path!");
|
||||
let mut bytes = Vec::new();
|
||||
File::open(path).expect("Couldn't open font file!").read_to_end(&mut bytes).unwrap();
|
||||
|
|
|
@ -70,7 +70,7 @@ pub fn init(connect: WebSocketCommunicate, connect_data: WebSocketConnectData, c
|
|||
|
||||
// URL that we actually fetch from the network, after applying the replacements
|
||||
// specified in the hosts file.
|
||||
let net_url_result = parse_url(replace_hosts(&connect_data.resource_url).as_url().unwrap());
|
||||
let net_url_result = parse_url(replace_hosts(&connect_data.resource_url).as_url());
|
||||
let net_url = match net_url_result {
|
||||
Ok(net_url) => net_url,
|
||||
Err(e) => {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -53,8 +53,8 @@ impl ServoUrl {
|
|||
Some(Arc::try_unwrap(self.0).unwrap_or_else(|s| (*s).clone()))
|
||||
}
|
||||
|
||||
pub fn as_url(&self) -> Option<&Arc<Url>> {
|
||||
Some(&self.0)
|
||||
pub fn as_url(&self) -> &Url {
|
||||
&self.0
|
||||
}
|
||||
|
||||
pub fn parse(input: &str) -> Result<Self, url::ParseError> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue