Skip to content

Commit f5df6a7

Browse files
committed
fix(lib/vscode): patch authority in asWebviewUri
We do this because resources in webviews don't load properly when the port is used in the resource uri. We're not sure why this is happening but adding this fix to get webviews working like before.
1 parent 56f0c4e commit f5df6a7

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/vscode/src/vs/workbench/api/common/shared/webview.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,12 @@ export function asWebviewUri(
5555
});
5656
}
5757

58+
// NOTE@coder: Add the port separately because if the port is in the domain the
59+
// URL will be invalid and the browser will not request it.
60+
const uri = new URL(resource.authority);
5861
return URI.from({
5962
scheme: Schemas.https,
60-
authority: `${resource.scheme}+${resource.authority}.${webviewRootResourceAuthority}`,
63+
authority: `${resource.scheme}+${uri.hostname}.${webviewRootResourceAuthority}` + uri.port ? (':' + uri.port) : '',
6164
path: resource.path,
6265
fragment: resource.fragment,
6366
query: resource.query,

lib/vscode/src/vs/workbench/contrib/webview/browser/pre/service-worker.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ async function processResourceRequest(event, requestUrl) {
256256

257257
const firstHostSegment = requestUrl.hostname.slice(0, requestUrl.hostname.length - (resourceBaseAuthority.length + 1));
258258
const scheme = firstHostSegment.split('+', 1)[0];
259-
const authority = firstHostSegment.slice(scheme.length + 1); // may be empty
259+
const authority = firstHostSegment.slice(scheme.length + 1) + requestUrl.port ? (':' + requestUrl.port) : ''; // may be empty
260260

261261
for (const parentClient of parentClients) {
262262
parentClient.postMessage({

0 commit comments

Comments
 (0)