formatLocationForDisplay() — react Function Reference
Architecture documentation for the formatLocationForDisplay() function in formatLocationForDisplay.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 0387a47c_28df_b84f_2410_96bf24210782["formatLocationForDisplay()"] b2ae7acd_23fc_8be6_1598_6a4162c47a7b["formatLocationForDisplay.js"] 0387a47c_28df_b84f_2410_96bf24210782 -->|defined in| b2ae7acd_23fc_8be6_1598_6a4162c47a7b 67de64c0_e785_eb7f_1bf3_db84aa6cc712["FormattedSourceString()"] 67de64c0_e785_eb7f_1bf3_db84aa6cc712 -->|calls| 0387a47c_28df_b84f_2410_96bf24210782 f14893ed_a642_91e8_4d09_870033938da3["CallSiteView()"] f14893ed_a642_91e8_4d09_870033938da3 -->|calls| 0387a47c_28df_b84f_2410_96bf24210782 style 0387a47c_28df_b84f_2410_96bf24210782 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-devtools-shared/src/devtools/views/Components/formatLocationForDisplay.js lines 13–48
export default function formatLocationForDisplay(
sourceURL: string,
line: number,
column: number,
): string {
// Metro can return JSC-safe URLs, which have `//&` as a delimiter
// https://www.npmjs.com/package/jsc-safe-url
const sanitizedSourceURL = sourceURL.includes('//&')
? toNormalUrl(sourceURL)
: sourceURL;
// Note: this RegExp doesn't work well with URLs from Metro,
// which provides bundle URL with query parameters prefixed with /&
const BEFORE_SLASH_RE = /^(.*)[\\\/]/;
let nameOnly = sanitizedSourceURL.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)) {
const match = sanitizedSourceURL.match(BEFORE_SLASH_RE);
if (match) {
const pathBeforeSlash = match[1];
if (pathBeforeSlash) {
const folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
nameOnly = folderName + '/' + nameOnly;
}
}
}
if (line === 0) {
return nameOnly;
}
return `${nameOnly}:${line}`;
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does formatLocationForDisplay() do?
formatLocationForDisplay() is a function in the react codebase, defined in packages/react-devtools-shared/src/devtools/views/Components/formatLocationForDisplay.js.
Where is formatLocationForDisplay() defined?
formatLocationForDisplay() is defined in packages/react-devtools-shared/src/devtools/views/Components/formatLocationForDisplay.js at line 13.
What calls formatLocationForDisplay()?
formatLocationForDisplay() is called by 2 function(s): CallSiteView, FormattedSourceString.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free