From f8fd0828e5eab7a673f3da47b5c574cda0d450b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerhard=20St=C3=B6bich?= <18708370+Flarna@users.noreply.github.com> Date: Tue, 2 Sep 2025 22:21:31 +0200 Subject: [PATCH] fs,win: do not add a second trailing slash in readdir Do not add a trailing slash if it was not removed by resolve in ToNamespacedPath. --- src/node_file.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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);