From 6eedc35a50ba60b5dac9ac6951eae9c8a46b548a Mon Sep 17 00:00:00 2001 From: Struan Bartlett Admin Date: Thu, 7 Sep 2023 21:58:48 +0000 Subject: [PATCH] Fix bug in handling Theia VSIX webview/mini-browser URIs - Bug introduced by commit 978a597 - webview and minibrowser URIs must be explicitly parsed --- app/server/lib/Proxy.pm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/server/lib/Proxy.pm b/app/server/lib/Proxy.pm index 399b77e..cdd8f85 100644 --- a/app/server/lib/Proxy.pm +++ b/app/server/lib/Proxy.pm @@ -45,13 +45,16 @@ sub domain_to_host { # - 1: 'my-devtainer', 'www', 'mydockside.co.uk', 1 (as seen by an inner Dockside devtainer; will proxy on to 'my-devtainer') if( $host =~ /^([^\.]+)\.(.*?)(:\d+)?$/ ) { - my @elements = reverse split(/--/, $1); + + # Split on two and only two dashes; these separate nested Dockside containers + my @elements = reverse split(/(*nlb:-)--(*nla:-)/, $1); my $domain = $2; - # Split again the leftmost element on its first '-'. + # Retain (e.g. 'ide') or e.g. 8eb55c33-985f-406e-b9e7-a8b0c4962e1e-wv- as $service # Add the devtainer name (if found) to @elements. # Always add the service name to @elements. - my ($service, $topHost) = pop(@elements) =~ /^([^-]+)(?:-(.*))?$/; + # See launch-ide.sh THEIA_WEBVIEW_EXTERNAL_ENDPOINT and THEIA_MINI_BROWSER_HOST_PATTERN. + my ($service, $topHost) = pop(@elements) =~ /^((?:.*-(?:wv|mb|webview|minibrowser)-)?[^-]+)(?:-(.*))?$/; push(@elements, $topHost ? $topHost : (), $service); my $nestCount = split(/-/, $r->header_in('X-Nest-Level'));