Skip to content

Commit 634dadb

Browse files
authored
Unmapper Windows compatibility (#3079)
* Switch to unix path separators before normalizing path for Windows compatibility * Add comment for posterity * Revert "Add comment for posterity" This reverts commit 742bace. * Strictly add comment
1 parent b17fa41 commit 634dadb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/react-error-overlay/src/utils/unmapper.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,19 @@ async function unmap(
5656
}
5757
let { fileName } = frame;
5858
if (fileName) {
59-
fileName = path.normalize(fileName);
59+
// The web version of this module only provides POSIX support, so Windows
60+
// paths like C:\foo\\baz\..\\bar\ cannot be normalized.
61+
// A simple solution to this is to replace all `\` with `/`, then
62+
// normalize afterwards.
63+
fileName = path.normalize(fileName.replace(/[\\]+/g, '/'));
6064
}
6165
if (fileName == null) {
6266
return frame;
6367
}
6468
const fN: string = fileName;
6569
const source = map
6670
.getSources()
71+
// Prepare path for normalization; see comment above for reasoning.
6772
.map(s => s.replace(/[\\]+/g, '/'))
6873
.filter(p => {
6974
p = path.normalize(p);

0 commit comments

Comments
 (0)