Skip to content

Commit f2252a8

Browse files
authored
fix: use fs::canonicalize to cover symlink edge cases (#284)
fixes #263
1 parent ee87dbc commit f2252a8

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/file_system.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ impl FileSystem for FileSystemOs {
172172
}
173173
} else if #[cfg(windows)] {
174174
dunce::canonicalize(path)
175-
} else {
175+
} else if #[cfg(target_family = "wasm")] {
176176
use std::path::Component;
177177
let mut path_buf = path.to_path_buf();
178178
loop {
@@ -184,15 +184,8 @@ impl FileSystem for FileSystemOs {
184184
path_buf.pop();
185185
}
186186
Component::Normal(seg) => {
187-
#[cfg(target_family = "wasm")]
188187
// Need to trim the extra \0 introduces by https://github.com/nodejs/uvwasi/issues/262
189-
{
190-
path_buf.push(seg.to_string_lossy().trim_end_matches('\0'));
191-
}
192-
#[cfg(not(target_family = "wasm"))]
193-
{
194-
path_buf.push(seg);
195-
}
188+
path_buf.push(seg.to_string_lossy().trim_end_matches('\0'));
196189
}
197190
Component::RootDir => {
198191
path_buf = PathBuf::from("/");
@@ -205,6 +198,8 @@ impl FileSystem for FileSystemOs {
205198
}
206199
}
207200
Ok(path_buf)
201+
} else {
202+
fs::canonicalize(path)
208203
}
209204
}
210205
}

0 commit comments

Comments
 (0)