Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 4 additions & 2 deletions src/connectionInfo/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ export class Connection extends Disposable {
if (!wsPath) {
wsPath = this.wsPath;
}
const wsPortUri = this.constructLocalUri(wsPort);
return vscode.Uri.joinPath(await vscode.env.asExternalUri(wsPortUri),wsPath); // ensure that this pathname is retained, as the websocket server must see this in order to authorize
const httpPortUri = this.constructLocalUri(wsPort);
const externalHttpUri = await vscode.env.asExternalUri(httpPortUri);
const externalWsUri = externalHttpUri.with({scheme : externalHttpUri.scheme === 'https' ? 'wss' : 'ws'});
return vscode.Uri.joinPath(externalWsUri, wsPath); // ensure that this pathname is retained, as the websocket server must see this in order to authorize
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/editorPreview/webviewComm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class WebviewComm extends Disposable {
this._panel.webview.html = this._getHtmlForWebview(
webview,
url,
`ws://${wsURI.authority}${wsURI.path}`,
`${wsURI.scheme}://${wsURI.authority}${wsURI.path}`,
`${httpHost.scheme}://${httpHost.authority}`
);

Expand Down
4 changes: 1 addition & 3 deletions src/server/serverUtils/HTMLInjector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ export class HTMLInjector extends Disposable {
wsUri = await this._connection.resolveExternalWSUri();
}

// if the HTTP scheme uses SSL, the WS scheme must also use SSL
const wsURL = `${httpUri.scheme === 'https' ? 'wss' : 'ws'}://${wsUri.authority
}${wsUri.path}`;
const wsURL = `${wsUri.scheme}://${wsUri.authority}${wsUri.path}`;
let httpURL = `${httpUri.scheme}://${httpUri.authority}`;

if (httpURL.endsWith('/')) {
Expand Down
4 changes: 2 additions & 2 deletions src/test/suite/connectionInfo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('ConnectionInfo', () => {

assert.ok(target.calledOnce);
const httpUri = vscode.Uri.parse('http://127.0.0.1:3000');
const wsUri = vscode.Uri.parse('http://127.0.0.1:3001/1234');
const wsUri = vscode.Uri.parse('ws://127.0.0.1:3001/1234');
assert.deepStrictEqual([
{
httpURI: httpUri,
Expand Down Expand Up @@ -103,7 +103,7 @@ describe('ConnectionInfo', () => {
await connection.connected();
assert(connection.workspace === undefined);
const httpUri = vscode.Uri.parse('http://127.0.0.1:3000');
const wsUri = vscode.Uri.parse('http://127.0.0.1:3001/1234');
const wsUri = vscode.Uri.parse('ws://127.0.0.1:3001/1234');

assert.ok(target.calledOnce);
assert.deepStrictEqual([
Expand Down