Skip to content

Commit 6aba26a

Browse files
jeanp413mustard-mh
authored andcommitted
return URL in resolveExternalUri
Tool: gitpod/catfood.gitpod.cloud
1 parent 4a152e9 commit 6aba26a

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/vs/gitpod/browser/workbench/workbench.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -845,19 +845,21 @@ async function doStart(): Promise<IDisposable> {
845845
if (!localhost) {
846846
return uri;
847847
}
848-
let externalEndpoint: URI;
848+
let externalEndpoint: URL;
849849
const tunnel = tunnels.get(localhost.port);
850850
if (tunnel) {
851-
externalEndpoint = URI.parse('http://localhost:' + tunnel.status.localPort);
851+
externalEndpoint = new URL('http://localhost:' + tunnel.status.localPort);
852852
} else {
853853
const publicUrl = (await vscode.commands.executeCommand('gitpod.resolveExternalPort', localhost.port)) as any as string;
854-
externalEndpoint = URI.parse(publicUrl);
854+
externalEndpoint = new URL(publicUrl);
855855
}
856-
return externalEndpoint.with({
857-
path: uri.path,
858-
query: uri.query,
859-
fragment: uri.fragment
860-
});
856+
externalEndpoint.pathname = uri.path.split('/').map(s => encodeURIComponent(s)).join('/');
857+
externalEndpoint.hash = encodeURIComponent(uri.fragment);
858+
// vscode uri is so buggy that if the query part of a url contains percent encoded '=' or '&', it will decode it internally and the url will be invalid forever
859+
// using /=(.*)/s we can split only on the first ocurrence of '=' if the value also contains a '='
860+
// sadly not the case if the value contains '&' as it's possible it could signal another query param
861+
uri.query.split('&').map(s => s.split(/=(.*)/s)).forEach(([k, v]) => !!k && externalEndpoint.searchParams.append(k.replaceAll('+', ' '), v?.replaceAll('+', ' ') || ''));
862+
return externalEndpoint;
861863
},
862864
homeIndicator: {
863865
href: info.gitpodHost,

0 commit comments

Comments
 (0)