Skip to content

Commit 4600d36

Browse files
author
Matt Bierner
committed
Fixing url patterns for port mapping
Fixes microsoft#102449 This also enables path mapping in non-remote cases, which was supported before last iteration
1 parent 7493065 commit 4600d36

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/vs/platform/webview/common/webviewPortMapping.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class WebviewPortMappingManager implements IDisposable {
2727
private readonly tunnelService: ITunnelService
2828
) { }
2929

30-
public async getRedirect(resolveAuthority: IAddress, url: string): Promise<string | undefined> {
30+
public async getRedirect(resolveAuthority: IAddress | null | undefined, url: string): Promise<string | undefined> {
3131
const uri = URI.parse(url);
3232
const requestLocalHostInfo = extractLocalHostUriMetaDataForPortMapping(uri);
3333
if (!requestLocalHostInfo) {
@@ -38,7 +38,7 @@ export class WebviewPortMappingManager implements IDisposable {
3838
if (mapping.webviewPort === requestLocalHostInfo.port) {
3939
const extensionLocation = this._getExtensionLocation();
4040
if (extensionLocation && extensionLocation.scheme === REMOTE_HOST_SCHEME) {
41-
const tunnel = await this.getOrCreateTunnel(resolveAuthority, mapping.extensionHostPort);
41+
const tunnel = resolveAuthority && await this.getOrCreateTunnel(resolveAuthority, mapping.extensionHostPort);
4242
if (tunnel) {
4343
if (tunnel.tunnelLocalPort === mapping.webviewPort) {
4444
return undefined;

src/vs/platform/webview/electron-main/webviewPortMappingProvider.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ export class WebviewPortMappingProvider extends Disposable {
3636

3737
sess.webRequest.onBeforeRequest({
3838
urls: [
39-
'*://localhost:*/',
40-
'*://127.0.0.1:*/',
41-
'*://0.0.0.0:*/',
39+
'*://localhost:*/*',
40+
'*://127.0.0.1:*/*',
41+
'*://0.0.0.0:*/*',
4242
]
4343
}, async (details, callback) => {
4444
const webviewId = details.webContentsId && this._webContentsIdsToWebviewIds.get(details.webContentsId);
@@ -47,7 +47,7 @@ export class WebviewPortMappingProvider extends Disposable {
4747
}
4848

4949
const entry = this._webviewData.get(webviewId);
50-
if (!entry || !entry.metadata.resolvedAuthority) {
50+
if (!entry) {
5151
return callback({});
5252
}
5353

0 commit comments

Comments
 (0)