From 2f651b2d64523bdd377d22b8b7213a04ad82f459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 2 May 2023 02:35:33 +0200 Subject: fix(npm): canonicalize filename before returning (#18948) This commit changes how paths for npm packages are handled, by canonicalizing them when resolving. This is done so that instead of returning "node_modules/@/node_modules//index.js" (which is a symlink) we "node_modules/@/index.js. Fixes https://github.com/denoland/deno/issues/18924 Fixes https://github.com/bluwy/create-vite-extra/issues/31 --------- Co-authored-by: David Sherret --- ext/fs/std_fs.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'ext/fs') diff --git a/ext/fs/std_fs.rs b/ext/fs/std_fs.rs index 49d113c01..4bdbf4943 100644 --- a/ext/fs/std_fs.rs +++ b/ext/fs/std_fs.rs @@ -647,15 +647,7 @@ fn metadata_to_fsstat(metadata: fs::Metadata) -> FsStat { } fn realpath(path: impl AsRef) -> FsResult { - let canonicalized_path = path.as_ref().canonicalize()?; - #[cfg(windows)] - let canonicalized_path = PathBuf::from( - canonicalized_path - .display() - .to_string() - .trim_start_matches("\\\\?\\"), - ); - Ok(canonicalized_path) + Ok(deno_core::strip_unc_prefix(path.as_ref().canonicalize()?)) } fn read_dir(path: impl AsRef) -> FsResult> { -- cgit v1.2.3