diff options
author | Mucha Naibei <muchajulius@gmail.com> | 2024-03-10 20:47:38 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-10 17:47:38 +0000 |
commit | 0bc685ed97c1cb2743ec2f1ef4d58f9298872fe6 (patch) | |
tree | e403b429ed1c6b9d38ffa8a6a4009894d7119600 /components/shared/net/blob_url_store.rs | |
parent | 67b277c992d59dfed7d9177d4a62a1517d28a5b5 (diff) | |
download | servo-0bc685ed97c1cb2743ec2f1ef4d58f9298872fe6.tar.gz servo-0bc685ed97c1cb2743ec2f1ef4d58f9298872fe6.zip |
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>
Diffstat (limited to 'components/shared/net/blob_url_store.rs')
-rw-r--r-- | components/shared/net/blob_url_store.rs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/components/shared/net/blob_url_store.rs b/components/shared/net/blob_url_store.rs index ab853b702c9..5e487b8038d 100644 --- a/components/shared/net/blob_url_store.rs +++ b/components/shared/net/blob_url_store.rs @@ -41,20 +41,24 @@ pub struct BlobBuf { /// Parse URL as Blob URL scheme's definition /// /// <https://w3c.github.io/FileAPI/#DefinitionOfScheme> -pub fn parse_blob_url(url: &ServoUrl) -> Result<(Uuid, FileOrigin), ()> { - let url_inner = Url::parse(url.path()).map_err(|_| ())?; +pub fn parse_blob_url(url: &ServoUrl) -> Result<(Uuid, FileOrigin), &'static str> { + let url_inner = Url::parse(url.path()).map_err(|_| "Failed to parse URL path")?; let segs = url_inner .path_segments() .map(|c| c.collect::<Vec<_>>()) - .ok_or(())?; + .ok_or("URL has no path segments")?; - if url.query().is_some() || segs.len() > 1 { - return Err(()); + if url.query().is_some() { + 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 = segs.first().ok_or(())?; - Uuid::from_str(id).map_err(|_| ())? + let id = segs.first().ok_or("URL has no path segments")?; + Uuid::from_str(id).map_err(|_| "Failed to parse UUID from path segment")? }; Ok((id, get_blob_origin(&ServoUrl::from_url(url_inner)))) } |