mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Fix more clippy warnings in components/shared/net
(#31548)
* Fix clippy warnings in components/shared * Fix build error * Fixes in order to solve some merge issues --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
67b277c992
commit
0bc685ed97
2 changed files with 15 additions and 11 deletions
|
@ -820,10 +820,10 @@ async fn scheme_fetch(
|
||||||
|
|
||||||
let (id, origin) = match parse_blob_url(&url) {
|
let (id, origin) = match parse_blob_url(&url) {
|
||||||
Ok((id, origin)) => (id, origin),
|
Ok((id, origin)) => (id, origin),
|
||||||
Err(()) => {
|
Err(error) => {
|
||||||
return Response::network_error(NetworkError::Internal(
|
return Response::network_error(NetworkError::Internal(format!(
|
||||||
"Invalid blob url".into(),
|
"Invalid blob URL ({error})"
|
||||||
));
|
)));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -41,20 +41,24 @@ pub struct BlobBuf {
|
||||||
/// Parse URL as Blob URL scheme's definition
|
/// Parse URL as Blob URL scheme's definition
|
||||||
///
|
///
|
||||||
/// <https://w3c.github.io/FileAPI/#DefinitionOfScheme>
|
/// <https://w3c.github.io/FileAPI/#DefinitionOfScheme>
|
||||||
pub fn parse_blob_url(url: &ServoUrl) -> Result<(Uuid, FileOrigin), ()> {
|
pub fn parse_blob_url(url: &ServoUrl) -> Result<(Uuid, FileOrigin), &'static str> {
|
||||||
let url_inner = Url::parse(url.path()).map_err(|_| ())?;
|
let url_inner = Url::parse(url.path()).map_err(|_| "Failed to parse URL path")?;
|
||||||
let segs = url_inner
|
let segs = url_inner
|
||||||
.path_segments()
|
.path_segments()
|
||||||
.map(|c| c.collect::<Vec<_>>())
|
.map(|c| c.collect::<Vec<_>>())
|
||||||
.ok_or(())?;
|
.ok_or("URL has no path segments")?;
|
||||||
|
|
||||||
if url.query().is_some() || segs.len() > 1 {
|
if url.query().is_some() {
|
||||||
return Err(());
|
return Err("URL should not contain a query");
|
||||||
|
}
|
||||||
|
|
||||||
|
if segs.len() > 1 {
|
||||||
|
return Err("URL should not have more than one path segment");
|
||||||
}
|
}
|
||||||
|
|
||||||
let id = {
|
let id = {
|
||||||
let id = segs.first().ok_or(())?;
|
let id = segs.first().ok_or("URL has no path segments")?;
|
||||||
Uuid::from_str(id).map_err(|_| ())?
|
Uuid::from_str(id).map_err(|_| "Failed to parse UUID from path segment")?
|
||||||
};
|
};
|
||||||
Ok((id, get_blob_origin(&ServoUrl::from_url(url_inner))))
|
Ok((id, get_blob_origin(&ServoUrl::from_url(url_inner))))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue