From 634dadb4400669d8aa6aa00b7072441f71a36ea7 Mon Sep 17 00:00:00 2001
From: Joe Haddad <timer150@gmail.com>
Date: Wed, 6 Sep 2017 14:42:40 -0400
Subject: [PATCH] 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 742baceef97e767527498a2ad8b2ab66ad748333.

* Strictly add comment
---
 packages/react-error-overlay/src/utils/unmapper.js | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/packages/react-error-overlay/src/utils/unmapper.js b/packages/react-error-overlay/src/utils/unmapper.js
index 60b2bee43..40f4528c0 100644
--- a/packages/react-error-overlay/src/utils/unmapper.js
+++ b/packages/react-error-overlay/src/utils/unmapper.js
@@ -56,7 +56,11 @@ 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;
@@ -64,6 +68,7 @@ async function unmap(
     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);
-- 
GitLab