Repository navigation
Conversation
On Windows, an absolute glob pattern without a drive letter, such as
'\Users\me\*.js' or '/Users/me/*.js', returned no results as soon as a
literal segment followed the root. The walker looks up a literal child
with Join(fullpath, name). For the drive-less root '\' that built
'\\Users', which Normalize() keeps as a UNC prefix, so the lookup
failed. path.win32.join() returns '\Users' here.
Skip the separator in Join() when the first part already ends with
one. Also queue the root with the platform separator: JoinEntry()
appends child names right after it, so a '/' leaked into results
('/Users\me').
Signed-off-by: Surafel Workayehu <surafelwork32@gmail.com>
On Windows, a glob pattern starting with '..' returned paths such as '../sib\a.js'. The walker queued the parent directory as '../', and JoinEntry() appends child names right after a trailing separator, so the '/' stayed in every result. The previous JS implementation built child paths with path.join(), which normalized it. Use the platform separator, as for the drive-less root. POSIX output is unchanged. Signed-off-by: Surafel Workayehu <surafelwork32@gmail.com>
Contributor
|
Welcome to Node.js, and thank you for your first contribution! Before review, please take a moment to read:
Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes two Windows regressions introduced by the native glob implementation in #65392. Both also affect v27.0.0-alpha.0.1.1. Node.js v26.x and earlier use the previous JavaScript implementation and are unaffected.
../sib/**/*.js..\sib\a.js../sib\a.js\Users\<user>\...\sib\*.js(no drive letter)\Users\<user>\...\sib\a.js[]Reproduction
Drive-less absolute patterns: Looking up a literal segment after the root
\calledJoin("\\", "Users"), producing\\Users.Normalize()preserved the leading backslashes as a UNC prefix, causing the lookup to fail and the glob to return no matches.Join()now avoids adding a separator when the first part already ends with one, matchingpath.win32.join()for this case. The root is also queued with the platform separator so returned paths do not start with/.Mixed separators in
..results: The parent directory was queued as the hardcoded string'../'. BecauseJoinEntry()appends child names directly after a trailing separator, the forward slash remained in returned paths. The parent directory now uses the platform separator.The previous JavaScript implementation used the same
'/'and'../'strings, but normalized child paths throughpath.join(). POSIX behavior is unchanged: the queued strings remain the same, andNormalize()already collapses the extra separator added byJoin().Tests
test/parallel/test-fs-glob-windows-no-drive-letter.mjs, covering drive-less patterns with backslashes, forward slashes, and a literal path across the callback, synchronous, and promises APIs.'../abs/*'and the literal control'../abs/foo'to the sharedpatternstable intest/parallel/test-fs-glob.mjs. The existing harness exercises both through all three APIs, includingfile:URL cwd,withFileTypes, andexclude.Verification
Both bugs were reproduced on Windows 11 with v28.0.0-nightly20261124d2c9ac02cb. The new tests fail on that nightly and pass on v26.13.1, which returns the expected results.
On Ubuntu 22.04, the same nightly passes the full
test-fs-glob.mjssuite, including the new..cases. The Windows-only test skips as expected.I have not built Node.js locally, so build and runtime verification of the fix remains for CI. Local checks included:
glob_walker.ccagainst the Node.js headers with clang-cl 19.Join()before and after the change againstpath.win32.join()andpath.posix.join(). In the cases checked, only drive-less root results changed; they now matchpath.win32.join(). POSIX results were unchanged.Refs: #65392