Skip to content

Commit

Permalink
Unmapper Windows compatibility (facebook#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 authored and thongdong7 committed Sep 24, 2017
1 parent 4661202 commit e8b42e0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/react-error-overlay/src/utils/unmapper.js
Original file line number Diff line number Diff line change
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 e8b42e0

Please sign in to comment.