Skip to content

Commit fe414b5

Browse files
committed
wip: asher fix
1 parent a2b34ea commit fe414b5

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

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

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

58-
// NOTE@coder (@jsjoeio)
59-
// We're not exactly sure how the resource.authority is used in the URI
60-
// but we noticed resources not loading correctly when the authority
61-
// contained a port like localhost:8080.
62-
// As a temporary workaround, we split the authority at the first colon
63-
// and use the first part e.g. localhost
64-
const [host, port] = resource.authority.split(':', 2)
65-
const authority = `${resource.scheme}+${host}.${webviewRootResourceAuthority}${port ? `:${port}` : ''}`;
66-
console.log(`show me the authority: ${authority}`);
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);
6761
return URI.from({
6862
scheme: Schemas.https,
69-
authority,
63+
authority: `${resource.scheme}+${uri.hostname}+${uri.port}.${webviewRootResourceAuthority}`,
7064
path: resource.path,
7165
fragment: resource.fragment,
7266
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) + port ? (":" + port) : ""
260260

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

0 commit comments

Comments
 (0)