You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Windows: path.parse rebuilds root/dir with backslashes where Node preserves input separators #10407
Found triaging #10385's Windows gap-suite failures (test_gap_node_path).
The divergence
$ node --experimental-strip-types test-files/test_gap_node_path.ts # Node 26.5.1, Windows
/
/home/user
$ ./test_gap_node_path.exe # Perry
\
\home\user
12 of the fixture's 14 lines match; only path.parse('/home/user/file.txt')'s root and dir differ.
Cause
js_path_win32_parse (crates/perry-runtime/src/path.rs:1578) reconstructs root and dir from parsed structure with hardcoded separators — r.push('\\'), d.push('\\'), head_segments.join("\\").
Node's win32.parse never rebuilds: every field is a slice of the input, so
whatever separator the caller wrote is what comes back. Perry is arguably more
"correctly win32" here, which is still a divergence.
The contract, measured on the pinned oracle
require('path').win32.parse(x) on Node 26.5.1 / Windows:
input
root
dir
base
/home/user/file.txt
/
/home/user
file.txt
C:/a/b/c.txt
C:/
C:/a/b
c.txt
C:\a\b\c.txt
C:\
C:\a\b
c.txt
//server/share/f.txt
//server/share/
//server/share/
f.txt
/a
/
/
a
\a\b
\
\a
b
C:foo/bar.txt
C:
C:foo
bar.txt
/a/b/
/
/a
b
C:/a/
C:/
C:/
a
/
/
/
(empty)
//
/
/
(empty)
C:
C:
C:
(empty)
a/b
(empty)
a
b
a
(empty)
(empty)
a
(empty)
(empty)
(empty)
(empty)
/a/b//c
/
/a/b/
c
C://a//b
C:/
C://a/
b
The rows that make this more than a separator swap: // roots to / (not UNC —
there is no share), repeated separators survive inside dir
(/a/b//c -> /a/b/), and a trailing separator is dropped for base while the
one before it is kept in dir.
Suggested fix
Derive root/dir/base as offsets into the input and slice, the way Node
does, instead of rebuilding from split_win32's components. The table above is
directly usable as a test vector.
Deliberately not attempted in #10385 / PR #10403: the rewrite touches every
Windows path consumer, and trading a known two-line divergence for unverified
behaviour across all of them needed more verification than that pass could give
it.
Context: one of 22 Windows-specific gap failures identified in #10403. The rest
cluster as fs/errno (5), locale/TZ (4), process/os (4), module resolution (2),
misc (5).
Activity