diff --git a/src/node_api.cc b/src/node_api.cc index fbe3d84fc20d12..f52e364c1cf35a 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -1,3 +1,4 @@ +#include "ada.h" #include "async_context_frame.h" #include "async_wrap-inl.h" #include "env-inl.h" @@ -722,11 +723,12 @@ void napi_module_register_by_symbol(v8::Local 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.