Skip to content

Commit 8318486

Browse files
committed
Adds & fix another test case when __virtual__ is at the root of the path
1 parent b71b3cb commit 8318486

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/fs.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ fn vpath(p: &Path) -> std::io::Result<VPath> {
243243

244244
if let Some((mut virtual_len, parent_depth)) = virtual_path_u8 {
245245
for _ in 0..parent_depth {
246+
if base_path_len == 1 {
247+
break;
248+
}
249+
246250
base_path_len -= 1;
247251
virtual_len += 1;
248252

@@ -415,6 +419,11 @@ mod tests {
415419
virtual_segments: Some(("a/b/__virtual__/foo-abcdef/2/c/foo.zip".into(), "c/foo.zip".into())),
416420
zip_path: "bar".into(),
417421
})))]
422+
#[case("/__virtual__/foo-abcdef/2/c/foo.zip/bar", Some(VPath::Zip(ZipInfo {
423+
base_path: "/".into(),
424+
virtual_segments: Some(("__virtual__/foo-abcdef/2/c/foo.zip".into(), "c/foo.zip".into())),
425+
zip_path: "bar".into(),
426+
})))]
418427
#[case("./a/b/c/.zip", None)]
419428
#[case("./a/b/c/foo.zipp", None)]
420429
#[case("./a/b/c/foo.zip/bar/baz/qux.zip", Some(VPath::Zip(ZipInfo {

0 commit comments

Comments
 (0)