diff --git a/src/node_file.cc b/src/node_file.cc index 6772fea0e1db30..6110de9448e3c0 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -1988,7 +1988,7 @@ static void ReadDir(const FunctionCallbackInfo& args) { ToNamespacedPath(env, &path); #ifdef _WIN32 - if (slashCheck) { + if (slashCheck && !path.ToStringView().ends_with("\\")) { size_t new_length = path.length() + 1; path.AllocateSufficientStorage(new_length + 1); path.SetLengthAndZeroTerminate(new_length);