When using the `mount' directive in PSGI (Plack::App::URLMap),
SCRIPT_NAME still needs to use a trailing slash before it can
be joined with another URL.
---
 lib/PublicInbox/Git.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index a1af776b..68f72052 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -461,10 +461,10 @@ sub local_nick ($) {
 sub host_prefix_url ($$) {
        my ($env, $url) = @_;
        return $url if index($url, '//') >= 0;
-       my $scheme = $env->{'psgi.url_scheme'};
        my $host_port = $env->{HTTP_HOST} //
                "$env->{SERVER_NAME}:$env->{SERVER_PORT}";
-       "$scheme://$host_port". ($env->{SCRIPT_NAME} || '/') . $url;
+       my $sn = $env->{SCRIPT_NAME} // '';
+       "$env->{'psgi.url_scheme'}://$host_port$sn/$url";
 }
 
 sub base_url { # for coderepos, PSGI-only

Reply via email to