diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-08-08 10:23:02 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-08 14:23:02 +0000 |
commit | 05f838a57cc5b5e7b262e1640baa4d93dfb0df28 (patch) | |
tree | f13f97b5988c537023c05033bf862c52e74d080c /cli/cache/http_cache/common.rs | |
parent | a037ed77a2b2dbef1d2c4175c0401738a13f13bd (diff) |
refactor: use deno_cache_dir crate (#20092)
Uses https://github.com/denoland/deno_cache/pull/26
Diffstat (limited to 'cli/cache/http_cache/common.rs')
-rw-r--r-- | cli/cache/http_cache/common.rs | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/cli/cache/http_cache/common.rs b/cli/cache/http_cache/common.rs deleted file mode 100644 index 690412293..000000000 --- a/cli/cache/http_cache/common.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. - -use std::path::Path; - -use deno_core::url::Url; - -pub fn base_url_to_filename_parts( - url: &Url, - port_separator: &str, -) -> Option<Vec<String>> { - let mut out = Vec::with_capacity(2); - - let scheme = url.scheme(); - out.push(scheme.to_string()); - - match scheme { - "http" | "https" => { - let host = url.host_str().unwrap(); - let host_port = match url.port() { - // underscores are not allowed in domains, so adding one here is fine - Some(port) => format!("{host}{port_separator}{port}"), - None => host.to_string(), - }; - out.push(host_port); - } - "data" | "blob" => (), - scheme => { - log::debug!("Don't know how to create cache name for scheme: {}", scheme); - return None; - } - }; - - Some(out) -} - -pub fn read_file_bytes(path: &Path) -> std::io::Result<Option<Vec<u8>>> { - match std::fs::read(path) { - Ok(s) => Ok(Some(s)), - Err(err) if err.kind() == std::io::ErrorKind::NotFound => Ok(None), - Err(err) => Err(err), - } -} |