summaryrefslogtreecommitdiff
path: root/ext/node/ops/require.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-12-14 16:09:05 +0100
committerGitHub <noreply@github.com>2023-12-14 15:09:05 +0000
commitac04787c30b67ba9c7fb800eae8361ba419e7f4e (patch)
tree0260d7b5ac0c94c1ec1220813c16ef9318be102e /ext/node/ops/require.rs
parent19d52b9a55a6d5a67f27cbcc6cbe9c6c15865d63 (diff)
fix(node): support resolving a package.json import to a builtin node module (#21576)
Closes https://github.com/denoland/deno/issues/21501
Diffstat (limited to 'ext/node/ops/require.rs')
-rw-r--r--ext/node/ops/require.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/ext/node/ops/require.rs b/ext/node/ops/require.rs
index 8010558c5..ada123686 100644
--- a/ext/node/ops/require.rs
+++ b/ext/node/ops/require.rs
@@ -431,7 +431,13 @@ where
NodeResolutionMode::Execution,
permissions,
)
- .map(|r| Some(r.to_string_lossy().to_string()))
+ .map(|r| {
+ Some(if r.scheme() == "file" {
+ r.to_file_path().unwrap().to_string_lossy().to_string()
+ } else {
+ r.to_string()
+ })
+ })
} else {
Ok(None)
}
@@ -515,7 +521,13 @@ where
NodeResolutionMode::Execution,
permissions,
)
- .map(|r| Some(r.to_string_lossy().to_string()))
+ .map(|r| {
+ Some(if r.scheme() == "file" {
+ r.to_file_path().unwrap().to_string_lossy().to_string()
+ } else {
+ r.to_string()
+ })
+ })
} else {
Ok(None)
}
@@ -588,7 +600,7 @@ where
NodeResolutionMode::Execution,
permissions,
)
- .map(|r| Some(Url::from_file_path(r).unwrap().to_string()))
+ .map(|r| Some(r.to_string()))
} else {
Ok(None)
}