Skip to content

Commit

Permalink
Changed to using just xxx/.. removeal in Path truncation
Browse files Browse the repository at this point in the history
  • Loading branch information
corigan01 committed Nov 18, 2023
1 parent 5498f1a commit 724eaa9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/fs/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,16 @@ impl Path {
.chain(["", "", ""])
.collect::<Vec<&str>>()
// Remove all "/path/../path/"
.windows(3)
.windows(2)
.scan(0_usize, |val, init| {
if *val > 0 {
return Some("");
}

let first = &init[0];
let second = &init[1];
let last = &init[2];

if (first == last && second == &"..") && first != &".." {
if second == &".." && first != &".." {
*val = 2;
Some(first)
} else {
Expand Down

0 comments on commit 724eaa9

Please sign in to comment.