Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Meta
create-react-app
Commits
742bacee
Commit
742bacee
authored
7 years ago
by
Joe Haddad
Browse files
Options
Download
Email Patches
Plain Diff
Add comment for posterity
parent
014fd4d0
1 merge request
!3079
Switch to unix path separators before normalizing path for Windows compatibility
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/react-error-overlay/src/utils/unmapper.js
+21
-2
packages/react-error-overlay/src/utils/unmapper.js
with
21 additions
and
2 deletions
+21
-2
packages/react-error-overlay/src/utils/unmapper.js
+
21
-
2
View file @
742bacee
...
...
@@ -27,6 +27,25 @@ function count(search: string, string: string): number {
return
count
;
}
function
normalizePath
(
_path
:
string
):
string
{
// `path.normalize` cleans a file path, (e.g. /foo//baz/..//bar/ becomes
// /foo/bar/).
// 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.
//
// Note:
// `path.normalize` supports POSIX forward slashes on Windows, but not the
// other way around. Converting all backslashes to forward slashes before
// normalizing makes this cross platform if it were isomorphic (used server
// side).
return
path
.
normalize
(
// Match contiguous backslashes
_path
.
replace
(
/
[\\]
+/g
,
'
/
'
)
);
}
/**
* Turns a set of mapped <code>StackFrame</code>s back into their generated code position and enhances them with code.
* @param {string} fileUri The URI of the <code>bundle.js</code> file.
...
...
@@ -56,7 +75,7 @@ async function unmap(
}
let
{
fileName
}
=
frame
;
if
(
fileName
)
{
fileName
=
path
.
normalize
(
fileName
.
replace
(
/
[\\]
+/g
,
'
/
'
)
);
fileName
=
normalize
Path
(
fileName
);
}
if
(
fileName
==
null
)
{
return
frame
;
...
...
@@ -64,7 +83,7 @@ async function unmap(
const
fN
:
string
=
fileName
;
const
source
=
map
.
getSources
()
.
map
(
s
=>
s
.
replace
(
/
[\\]
+/g
,
'
/
'
)
)
.
map
(
normalizePath
)
.
filter
(
p
=>
{
p
=
path
.
normalize
(
p
);
const
i
=
p
.
lastIndexOf
(
fN
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets