diff --git a/components/gfx/platform/macos/font_template.rs b/components/gfx/platform/macos/font_template.rs index 3465f935360..3cd5fecdb01 100644 --- a/components/gfx/platform/macos/font_template.rs +++ b/components/gfx/platform/macos/font_template.rs @@ -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(); diff --git a/components/net/websocket_loader.rs b/components/net/websocket_loader.rs index d0ce7d61836..186909c9314 100644 --- a/components/net/websocket_loader.rs +++ b/components/net/websocket_loader.rs @@ -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) => { diff --git a/components/script/dom/url.rs b/components/script/dom/url.rs index 6c9139e99fc..cf8a6201f8b 100644 --- a/components/script/dom/url.rs +++ b/components/script/dom/url.rs @@ -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)]) { diff --git a/components/script/dom/urlhelper.rs b/components/script/dom/urlhelper.rs index 5037d7fb733..e001faf7a81 100644 --- a/components/script/dom/urlhelper.rs +++ b/components/script/dom/urlhelper.rs @@ -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() { diff --git a/components/script/dom/websocket.rs b/components/script/dom/websocket.rs index 367d67d440d..296141a6c3a 100644 --- a/components/script/dom/websocket.rs +++ b/components/script/dom/websocket.rs @@ -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. diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 3f89e7adf00..b390c44217a 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -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); diff --git a/components/url/lib.rs b/components/url/lib.rs index 9e3948fc5ab..766c5bd5f5c 100644 --- a/components/url/lib.rs +++ b/components/url/lib.rs @@ -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> { - Some(&self.0) + pub fn as_url(&self) -> &Url { + &self.0 } pub fn parse(input: &str) -> Result {