From db58bf46615f6bde0f8cf7f8aa19252201f48086 Mon Sep 17 00:00:00 2001 From: Joe Haddad 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 60b2bee432b..40f4528c0e4 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);