@@ -74,7 +74,12 @@ function replaceWindowsLineEndings(str) {
7474// Replaces all Windows path separators with posix separators for unified snapshots
7575// across platforms.
7676function replaceWindowsPaths ( str ) {
77- return common . isWindows ? str . replaceAll ( path . win32 . sep , path . posix . sep ) : str ;
77+ if ( ! common . isWindows ) {
78+ return str ;
79+ }
80+ // Only replace `\` and `\\` with a leading letter, colon, or a `.`.
81+ // Avoid replacing escaping patterns like ` \#`, `\ `, or `\\`.
82+ return str . replaceAll ( / (?< = ( \w : | \. | \w + ) (?: \S | \\ ) * ) \\ \\ ? / g, '/' ) ;
7883}
7984
8085// Removes line trailing white spaces.
@@ -224,10 +229,6 @@ function replaceJunitDuration(str) {
224229 . replaceAll ( / f i l e = " [ ^ " ] * " / g, 'file="*"' ) ;
225230}
226231
227- function removeWindowsPathEscaping ( str ) {
228- return common . isWindows ? str . replaceAll ( / \\ \\ / g, '\\' ) : str ;
229- }
230-
231232// The Node test coverage returns results for all files called by the test. This
232233// will make the output file change if files like test/common/index.js change.
233234// This transform picks only the first line and then the lines from the test
@@ -254,7 +255,6 @@ function pickTestFileFromLcov(str) {
254255const basicTransform = transform (
255256 replaceWindowsLineEndings ,
256257 replaceTrailingSpaces ,
257- removeWindowsPathEscaping ,
258258 replaceWindowsPaths ,
259259 replaceNodeVersion ,
260260 generalizeExeName ,
0 commit comments