-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
minimal reproduction
import { HttpCache } from "@deno/cache-dir";
const httpCache = await HttpCache.create({
root: "<path>",
vendorRoot:
"<path>",
readOnly: false,
});
httpCache.set(
new URL("data:text/javascript"),
{},
Deno.readFileSync(
"<path>"
)
);Error
panicked at rs_lib/src/local.rs:673:67:
index out of bounds: the len is 0 but the index is 0
Problem
local.rs
let scheme = base_parts.remove(0);
base_parts[0] = Cow::Owned(format!("{}_{}", scheme, base_parts[0]));https://github.com/denoland/deno_cache_dir/blob/main/rs_lib/src/local.rs#L673
common.rs
pub fn base_url_to_filename_parts<'a>(
url: &'a Url,
port_separator: &str,
) -> Option<Vec<Cow<'a, str>>> {
match scheme {
"data" | "blob" => {
out.push(Cow::Borrowed(scheme));
}
};https://github.com/denoland/deno_cache_dir/blob/main/rs_lib/src/common.rs#L34
Because of the data: scheme, there is only one Vec.push() happening, so the vector will always have length 1.
Vec.remove mutates the vector from length 1 to length 0 and then the vector is accessed at index 0.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels