diff --git a/src/vs/workbench/contrib/remote/browser/tunnelView.ts b/src/vs/workbench/contrib/remote/browser/tunnelView.ts index 235dce5467eba42bb646e0e81a72685f84bdd6b9..713dc9db08151d1f8042e77ad57488b134ae7b11 100644 --- a/src/vs/workbench/contrib/remote/browser/tunnelView.ts +++ b/src/vs/workbench/contrib/remote/browser/tunnelView.ts @@ -414,13 +414,23 @@ class TunnelItem implements ITunnelItem { if (address.length < 16) { return address; } - let url: URL | undefined; + let displayAddress: string = address; try { - url = new URL(address); + if (!address.startsWith('http')) { + address = `https://${address}`; + } + const url = new URL(address); + if (url && url.host) { + const lastDotIndex = url.host.lastIndexOf('.'); + const secondLastDotIndex = lastDotIndex !== -1 ? url.host.substring(0, lastDotIndex).lastIndexOf('.') : -1; + if (secondLastDotIndex !== -1) { + displayAddress = `${url.protocol}//...${url.host.substring(secondLastDotIndex + 1)}`; + } + } } catch (e) { // Address isn't a valid url and can't be compacted. } - return url && url.host.length > 0 ? url.host : address; + return displayAddress; } set description(description: string | undefined) { @@ -430,8 +440,8 @@ class TunnelItem implements ITunnelItem { get description(): string | undefined { if (this._description) { return this._description; - } else if (this.name) { - return nls.localize('remote.tunnelsView.forwardedPortDescription0', "{0} \u2192 {1}", this.remotePort, this.localAddress); + } else if (this.name && this.localAddress) { + return nls.localize('remote.tunnelsView.forwardedPortDescription0', "{0} \u2192 {1}", this.remotePort, TunnelItem.compactLongAddress(this.localAddress)); } return undefined; } @@ -877,7 +887,10 @@ export namespace OpenPortInBrowserAction { const tunnel = model.forwarded.get(key) || model.detected.get(key); let address: string | undefined; if (tunnel && tunnel.localAddress && (address = model.address(tunnel.remoteHost, tunnel.remotePort))) { - return openerService.open(URI.parse('http://' + address)); + if (!address.startsWith('http')) { + address = `https://${address}`; + } + return openerService.open(URI.parse(address)); } return Promise.resolve(); }