From: Junio C Hamano Date: Thu, 09 Feb 2023 23:05:20 GMT Subject: Re: [PATCH v2] gitweb: fix base url set if PATH_INFO is used, add a / at the end Message-ID: In-Reply-To: <20230209222648.z-sqdvWiK7xa-NLagt3B_X_4bFQJBsA8cA06YvgXqWQ@z> Daniel Abrecht writes: > In HTML, if there is a base tag like ``, a relative > URL like > `c/d` will be resolved by the browser as `a/c/d` and not as > `a/b/c/d`. But with > a base tag like `` it will result in `a/b/c/d`. > > Signed-off-by: Daniel Abrecht > --- > gitweb/gitweb.perl | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl > index e66eb3d9ba..edcee1652c 100755 > --- a/gitweb/gitweb.perl > +++ b/gitweb/gitweb.perl > @@ -74,6 +74,11 @@ sub evaluate_uri { > } > } > > + # $base_url is later used in the tag as a URL, if it > doesn't end in a / It seems an overlog line was wrapped around and broke the patch. > + # the browser will strip away the last component for relative URLs. > + # Add the / if it's missing. The above is not an incorrect statement per-se, but if $base were pointing at the document, we would likely break if we add an extra slash. Don't we want to say something like # $base_url at this point points at a directory, not a # single document, and later is used in the tag. # Make sure it ends in a '/'. Otherwise, we'd lose the last # component when forming a relative URL. perhaps? > + $base_url .= '/' if not $base_url =~ /\/$/; > + > # target of the home link on top of all pages > our $home_link = $my_uri || "/"; > }