summaryrefslogtreecommitdiff
path: root/ext/napi
diff options
context:
space:
mode:
authorsnek <snek@deno.com>2024-06-19 11:33:46 -0700
committerGitHub <noreply@github.com>2024-06-19 11:33:46 -0700
commit293a36f98d3614368d24f7804d2fc4191a54c0e3 (patch)
treebea097934bd7264318dba5762a369267d7ceea9e /ext/napi
parent6c6ee02dfdb0f158a0aab20905e362100b2c3328 (diff)
fix: more node-api fixes (#24220)
- add fallback impls of external string apis which always copy. after upstream changes to rusty_v8 we can support non-copying api as well. - `napi_get_buffer_data` needs to work on all TypedArray instances. - Fixes: https://github.com/denoland/deno/issues/24209 - `target_defaults.default_configuration` is used by some modules to find the corresponding node file from node-gyp - `node_api_get_module_filename` expects the filename to be a `file:` url.
Diffstat (limited to 'ext/napi')
-rw-r--r--ext/napi/lib.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/ext/napi/lib.rs b/ext/napi/lib.rs
index 402785ce8..829839838 100644
--- a/ext/napi/lib.rs
+++ b/ext/napi/lib.rs
@@ -9,6 +9,7 @@ use core::ptr::NonNull;
use deno_core::error::type_error;
use deno_core::error::AnyError;
use deno_core::op2;
+use deno_core::url::Url;
use deno_core::ExternalOpsTracker;
use deno_core::OpState;
use deno_core::V8CrossThreadTaskSpawner;
@@ -528,7 +529,10 @@ where
let type_tag = v8::Private::new(scope, Some(type_tag_name));
let type_tag = v8::Global::new(scope, type_tag);
- let env_shared = EnvShared::new(napi_wrap, type_tag, path.clone());
+ let url_filename =
+ Url::from_file_path(&path).map_err(|_| type_error("Invalid path"))?;
+ let env_shared =
+ EnvShared::new(napi_wrap, type_tag, format!("{url_filename}\0"));
let ctx = scope.get_current_context();
let mut env = Env::new(