Skip to content

Commit

Permalink
module,win: fix long path resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanStojanovic committed Dec 8, 2023
1 parent 8cdb7ca commit e74bcf7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/node_file.cc
Expand Up @@ -2916,6 +2916,9 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {

for (int i = 0; i < legacy_main_extensions_with_main_end; i++) {
file_path = *initial_file_path + std::string(legacy_main_extensions[i]);
#ifdef _WIN32
file_path = "\\\\?\\" + file_path;
#endif

switch (FilePathIsFile(env, file_path)) {
case BindingData::FilePathIsFileReturnType::kIsFile:
Expand Down Expand Up @@ -2953,6 +2956,9 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
i < legacy_main_extensions_package_fallback_end;
i++) {
file_path = *initial_file_path + std::string(legacy_main_extensions[i]);
#ifdef _WIN32
file_path = "\\\\?\\" + file_path;
#endif

switch (FilePathIsFile(env, file_path)) {
case BindingData::FilePathIsFileReturnType::kIsFile:
Expand Down
5 changes: 5 additions & 0 deletions src/node_modules.cc
Expand Up @@ -256,8 +256,13 @@ void BindingData::ReadPackageJSON(const FunctionCallbackInfo<Value>& args) {
permission::PermissionScope::kFileSystemRead,
path.ToStringView());

#ifdef _WIN32
auto package_json = GetPackageJSON(
realm, "\\\\?\\" + path.ToString(), is_esm ? &error_context : nullptr);
#else
auto package_json =
GetPackageJSON(realm, path.ToString(), is_esm ? &error_context : nullptr);
#endif
if (package_json == nullptr) {
return;
}
Expand Down

0 comments on commit e74bcf7

Please sign in to comment.