Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions packages/react-devtools-shared/src/symbolicateSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ async function symbolicateSource(
resourceLine.length,
);

const sourceMap = await fetchFileWithCaching(sourceMapURL).catch(
() => null,
);
const sourceMap = await fetchFileWithCaching(
new URL(sourceMapURL, sourceURL).toString(),
).catch(() => null);
Comment thread
Jack-Works marked this conversation as resolved.
Outdated
if (sourceMap != null) {
try {
const parsedSourceMap = JSON.parse(sourceMap);
Expand All @@ -91,22 +91,20 @@ async function symbolicateSource(
return {sourceURL: normalizedURL, line, column};
} catch (e) {
// This is not valid URL
if (possiblyURL.startsWith('/')) {
// /path or X:\\path
if (
possiblyURL.startsWith('/') ||
possiblyURL.slice(1).startsWith(':\\\\')
) {
// This is an absolute path
return {sourceURL: possiblyURL, line, column};
}

// This is a relative path
const [sourceMapAbsolutePathWithoutQueryParameters] =
sourceMapURL.split(/[?#&]/);

const absoluteSourcePath =
sourceMapAbsolutePathWithoutQueryParameters +
(sourceMapAbsolutePathWithoutQueryParameters.endsWith('/')
? ''
: '/') +
possiblyURL;

const absoluteSourcePath = new URL(
possiblyURL,
sourceMapURL,
).toString();
return {sourceURL: absoluteSourcePath, line, column};
}
} catch (e) {
Expand Down
3 changes: 1 addition & 2 deletions packages/react-devtools-shared/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,6 @@ export function backendToFrontendSerializedElementMapper(
};
}

// This is a hacky one to just support this exact case.
export function normalizeUrl(url: string): string {
return url.replace('/./', '/');
return new URL(url).toString();
Comment thread
Jack-Works marked this conversation as resolved.
Outdated
}