Skip to content

Commit

Permalink
Update canonicalize
Browse files Browse the repository at this point in the history
  • Loading branch information
MonicaOlejniczak committed Jul 30, 2024
1 parent 290ce6d commit abf7fd1
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions crates/parcel_filesystem/src/in_memory_file_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,25 @@ impl InMemoryFileSystem {
}

fn canonicalize_impl(&self, path: &Path) -> PathBuf {
let cwd = self.current_working_directory.read().unwrap();
let mut result = if path.is_absolute() {
vec![]
} else {
cwd.components().collect()
};

let components = path.components();
for component in components {
let mut path = path.to_path_buf();
if path.is_relative() {
path = self
.current_working_directory
.read()
.unwrap()
.to_path_buf()
.join(path);
}

let mut result = Vec::new();

for component in path.components() {
match component {
Component::Prefix(prefix) => {
result = vec![Component::Prefix(prefix)];
result.push(Component::Prefix(prefix));
}
Component::RootDir => {
result = vec![Component::RootDir];
result.push(Component::RootDir);
}
Component::CurDir => {}
Component::ParentDir => {
Expand Down

0 comments on commit abf7fd1

Please sign in to comment.