Skip to content

Commit

Permalink
Moved RegExp declaration into function basedon PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Dec 10, 2019
1 parent 1252a00 commit 040b28c
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,12 @@ function InspectedElementView({
);
}

// The function below (formatSourceForDisplay) is based on packages/shared/describeComponentFrame.js
const BEFORE_SLASH_RE = /^(.*)[\\\/]/;
// This function is based on packages/shared/describeComponentFrame.js
function formatSourceForDisplay(fileName: string, lineNumber: string) {
const BEFORE_SLASH_RE = /^(.*)[\\\/]/;

let nameOnly = fileName.replace(BEFORE_SLASH_RE, '');

// In DEV, include code for a common special case:
// prefer "folder/index.js" instead of just "index.js".
if (/^index\./.test(nameOnly)) {
Expand All @@ -429,6 +431,7 @@ function formatSourceForDisplay(fileName: string, lineNumber: string) {
}
}
}

return `${nameOnly}:${lineNumber}`;
}

Expand Down

0 comments on commit 040b28c

Please sign in to comment.