in src/devtoolsPanel.ts [376:423]
private async parseUrlToUri(url: string): Promise<vscode.Uri | undefined> {
// Convert the devtools url into a local one
let sourcePath = url;
let appendedEntryPoint = false;
if (this.config.defaultEntrypoint) {
// If sourcePath is just a baseUrl, append to default entrypoint
try {
const oldSourePath = sourcePath;
sourcePath = addEntrypointIfNeeded(sourcePath, this.config.defaultEntrypoint);
appendedEntryPoint = oldSourePath !== sourcePath;
} catch (e) {
await ErrorReporter.showInformationDialog({
errorCode: ErrorCodes.Error,
title: 'Unable to open file in editor.',
message: `'${sourcePath}' is not a valid url.`,
});
return;
}
}
if (this.config.sourceMaps) {
sourcePath = applyPathMapping(sourcePath, this.config.sourceMapPathOverrides);
}
// Convert the local url to a workspace path
const transformer = new debugCore.UrlPathTransformer();
void transformer.launch({ pathMapping: this.config.pathMapping });
// origin in this case is trivial since we expect fixSource to take it out
// marking it explicitly as invalid to clarify intention.
const localSource = { path: sourcePath, origin: 'invalid-origin://' };
await transformer.fixSource(localSource);
// per documentation if the file was correctly resolved origin will be cleared.
// https://github.com/Microsoft/vscode-chrome-debug-core/blob/main/src/transformers/urlPathTransformer.ts
if (!localSource.origin) {
// Convert the workspace path into a VS Code url
const uri = vscode.Uri.file(localSource.path);
return uri;
}
// If failed to resolve origin, it's possible entrypoint needs to be updated.
// Space at beginning to allow insertion in message below
const entryPointErrorMessage = ` Consider updating the 'Default Entrypoint' setting to map to your root html page. The current setting is '${this.config.defaultEntrypoint}'.`;
await ErrorReporter.showInformationDialog({
errorCode: ErrorCodes.Error,
title: 'Unable to open file in editor.',
message: `${sourcePath} does not map to a local file.${appendedEntryPoint ? entryPointErrorMessage : ''}`,
});
}