Redact stack traces with forward and backslashes
This commit is contained in:
parent
b0da7d965e
commit
a8a7525609
2 changed files with 27 additions and 2 deletions
|
@ -37,10 +37,16 @@ exports._redactPath = (filePath) => {
|
|||
// _pathToRegExp :: Path -> Maybe RegExp
|
||||
exports._pathToRegExp = (filePath) => {
|
||||
try {
|
||||
const pathWithNormalizedSlashes = filePath.replace(/\//g, '\\');
|
||||
const urlEncodedPath = encodeURI(filePath);
|
||||
// Safe `String::replaceAll`:
|
||||
// https://github.com/lodash/lodash/issues/1084#issuecomment-86698786
|
||||
const urlEncodedAppRootPath = escapeRegExp(encodeURI(filePath));
|
||||
return new RegExp(`${escapeRegExp(filePath)}|${urlEncodedAppRootPath}`, 'g');
|
||||
const patternString = [
|
||||
filePath,
|
||||
pathWithNormalizedSlashes,
|
||||
urlEncodedPath,
|
||||
].map(escapeRegExp).join('|');
|
||||
return new RegExp(patternString, 'g');
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue