Skip to content

Commit 0df3eb0

Browse files
committed
node-api: preserve URL filenames without conversion
1 parent 641653b commit 0df3eb0

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/node_api.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -722,11 +722,12 @@ void napi_module_register_by_symbol(v8::Local<v8::Object> exports,
722722
filename_js->IsString()) {
723723
node::Utf8Value filename(node_env->isolate(), filename_js);
724724

725-
// Turn the absolute path into a URL. Currently the absolute path is always
726-
// a file system path.
727-
// TODO(gabrielschulhof): Pass the `filename` through unchanged if/when we
728-
// receive it as a URL already.
729-
module_filename = node::url::FromFilePath(filename.ToStringView());
725+
const auto filename_view = filename.ToStringView();
726+
if (filename_view.find("://") != std::string_view::npos) {
727+
module_filename = filename_view;
728+
} else {
729+
module_filename = node::url::FromFilePath(filename_view);
730+
}
730731
}
731732

732733
// Create a new napi_env for this specific module.

0 commit comments

Comments
 (0)