Skip to content

Commit e74bcf7

Browse files
module,win: fix long path resolve
Fixes: #50753
1 parent 8cdb7ca commit e74bcf7

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/node_file.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2916,6 +2916,9 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
29162916

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

29202923
switch (FilePathIsFile(env, file_path)) {
29212924
case BindingData::FilePathIsFileReturnType::kIsFile:
@@ -2953,6 +2956,9 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
29532956
i < legacy_main_extensions_package_fallback_end;
29542957
i++) {
29552958
file_path = *initial_file_path + std::string(legacy_main_extensions[i]);
2959+
#ifdef _WIN32
2960+
file_path = "\\\\?\\" + file_path;
2961+
#endif
29562962

29572963
switch (FilePathIsFile(env, file_path)) {
29582964
case BindingData::FilePathIsFileReturnType::kIsFile:

src/node_modules.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,13 @@ void BindingData::ReadPackageJSON(const FunctionCallbackInfo<Value>& args) {
256256
permission::PermissionScope::kFileSystemRead,
257257
path.ToStringView());
258258

259+
#ifdef _WIN32
260+
auto package_json = GetPackageJSON(
261+
realm, "\\\\?\\" + path.ToString(), is_esm ? &error_context : nullptr);
262+
#else
259263
auto package_json =
260264
GetPackageJSON(realm, path.ToString(), is_esm ? &error_context : nullptr);
265+
#endif
261266
if (package_json == nullptr) {
262267
return;
263268
}

0 commit comments

Comments
 (0)