Skip to content

Commit 5b7b86c

Browse files
committed
Fixes trailing slashes
1 parent 9094b7d commit 5b7b86c

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pnp"
3-
version = "0.5.2"
3+
version = "0.5.3"
44
edition = "2021"
55
license = "BSD-2-Clause"
66
description = "Resolution primitives for Yarn PnP"

src/fs.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,9 @@ pub fn split_zip(p_bytes: &[u8]) -> (&[u8], Option<&[u8]>) {
232232
continue;
233233
}
234234

235-
let zip_path = &p_bytes[0..next_char_idx + 1];
235+
let zip_path = &p_bytes[0..next_char_idx];
236236
let sub_path = p_bytes.get(next_char_idx + 1..);
237-
237+
238238
return (zip_path, sub_path);
239239
} else {
240240
break;
@@ -300,7 +300,7 @@ pub fn vpath(p: &Path) -> std::io::Result<VPath> {
300300
return Err(std::io::Error::new(std::io::ErrorKind::Other, "Invalid virtual back-reference"))
301301
}
302302

303-
base_path_u8 = &archive_path_u8[0..base_path_len];
303+
base_path_u8 = &archive_path_u8[0..base_path_len - 1];
304304

305305
virtual_segments = Some((
306306
io_bytes_to_str(&archive_path_u8[base_path_len..archive_path_u8.len()])?.to_string(),
@@ -370,52 +370,52 @@ mod tests {
370370
["foo", null],
371371
["foo.zip", null],
372372
["foo.zip/bar", {
373-
"basePath": "foo.zip/",
373+
"basePath": "foo.zip",
374374
"virtualSegments": null,
375375
"zipPath": "bar"
376376
}],
377377
["foo.zip/bar/baz", {
378-
"basePath": "foo.zip/",
378+
"basePath": "foo.zip",
379379
"virtualSegments": null,
380380
"zipPath": "bar/baz"
381381
}],
382382
["/a/b/c/foo.zip", null],
383383
["./a/b/c/foo.zip", null],
384384
["./a/b/__virtual__/abcdef/0/c/d", {
385-
"basePath": "a/b/",
385+
"basePath": "a/b",
386386
"virtualSegments": ["__virtual__/abcdef/0/c/d", "c/d"],
387387
"zipPath": null
388388
}],
389389
["./a/b/__virtual__/abcdef/1/c/d", {
390-
"basePath": "a/",
390+
"basePath": "a",
391391
"virtualSegments": ["b/__virtual__/abcdef/1/c/d", "c/d"],
392392
"zipPath": null
393393
}],
394394
["./a/b/__virtual__/abcdef/0/c/foo.zip/bar", {
395-
"basePath": "a/b/",
396-
"virtualSegments": ["__virtual__/abcdef/0/c/foo.zip/", "c/foo.zip/"],
395+
"basePath": "a/b",
396+
"virtualSegments": ["__virtual__/abcdef/0/c/foo.zip", "c/foo.zip"],
397397
"zipPath": "bar"
398398
}],
399399
["./a/b/__virtual__/abcdef/1/c/foo.zip/bar", {
400-
"basePath": "a/",
401-
"virtualSegments": ["b/__virtual__/abcdef/1/c/foo.zip/", "c/foo.zip/"],
400+
"basePath": "a",
401+
"virtualSegments": ["b/__virtual__/abcdef/1/c/foo.zip", "c/foo.zip"],
402402
"zipPath": "bar"
403403
}],
404404
["./a/b/c/.zip", null],
405405
["./a/b/c/foo.zipp", null],
406406
["./a/b/c/foo.zip/bar/baz/qux.zip", {
407-
"basePath": "a/b/c/foo.zip/",
407+
"basePath": "a/b/c/foo.zip",
408408
"virtualSegments": null,
409409
"zipPath": "bar/baz/qux.zip"
410410
}],
411411
["./a/b/c/foo.zip-bar.zip", null],
412412
["./a/b/c/foo.zip-bar.zip/bar/baz/qux.zip", {
413-
"basePath": "a/b/c/foo.zip-bar.zip/",
413+
"basePath": "a/b/c/foo.zip-bar.zip",
414414
"virtualSegments": null,
415415
"zipPath": "bar/baz/qux.zip"
416416
}],
417417
["./a/b/c/foo.zip-bar/foo.zip-bar/foo.zip-bar.zip/d", {
418-
"basePath": "a/b/c/foo.zip-bar/foo.zip-bar/foo.zip-bar.zip/",
418+
"basePath": "a/b/c/foo.zip-bar/foo.zip-bar/foo.zip-bar.zip",
419419
"virtualSegments": null,
420420
"zipPath": "d"
421421
}]

0 commit comments

Comments
 (0)