Skip to content

node-api: preserve URL filenames without conversion #58578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/node_api.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "ada.h"
#include "async_context_frame.h"
#include "async_wrap-inl.h"
#include "env-inl.h"
Expand Down Expand Up @@ -722,11 +723,12 @@ void napi_module_register_by_symbol(v8::Local<v8::Object> exports,
filename_js->IsString()) {
node::Utf8Value filename(node_env->isolate(), filename_js);

// Turn the absolute path into a URL. Currently the absolute path is always
// a file system path.
// TODO(gabrielschulhof): Pass the `filename` through unchanged if/when we
// receive it as a URL already.
module_filename = node::url::FromFilePath(filename.ToStringView());
const auto filename_view = filename.ToStringView();
if (ada::can_parse(filename_view)) {
module_filename = filename_view;
} else {
module_filename = node::url::FromFilePath(filename_view);
}
}

// Create a new napi_env for this specific module.
Expand Down
Loading