Skip to content

Commit

Permalink
Unmapper Windows compatibility (#3079)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Timer committed Sep 6, 2017
1 parent b17fa41 commit 634dadb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/react-error-overlay/src/utils/unmapper.js
Expand Up @@ -56,14 +56,19 @@ async function unmap(
}
let { fileName } = frame;
if (fileName) {
fileName = path.normalize(fileName);
// The web version of this module only provides POSIX support, so Windows
// paths like C:\foo\\baz\..\\bar\ cannot be normalized.
// A simple solution to this is to replace all `\` with `/`, then
// normalize afterwards.
fileName = path.normalize(fileName.replace(/[\\]+/g, '/'));
}
if (fileName == null) {
return frame;
}
const fN: string = fileName;
const source = map
.getSources()
// Prepare path for normalization; see comment above for reasoning.
.map(s => s.replace(/[\\]+/g, '/'))
.filter(p => {
p = path.normalize(p);
Expand Down

0 comments on commit 634dadb

Please sign in to comment.