git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] gitweb: fix base url set if PATH_INFO is used, add a / at the end.

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 6, 2023, 22:02 UTC
Message-ID
<xmqqsffi4fmm.fsf@gitster.g>
In-Reply-To
<585496b18c853140144c3e7ae13c0124@abrecht.li>
Daniel Abrecht <git-git@nodmarc.danielabrecht.ch> writes:
Show 22 quoted lines
> In HTML, if there is a base tag like `<base href="/a/b">`,
> 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
> `<base href="/a/b/">` it will result in `a/b/c/d`. So by
> adding a slash there, the browser should now search the
> files at the correct location.
>
> Signed-off-by: Daniel Abrecht <public@danielabrecht.ch>
> ---
>  gitweb/gitweb.perl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index e66eb3d9ba..acb2cce5f6 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -4217,7 +4217,7 @@ sub git_header_html {
>  	# the stylesheet, favicon etc urls won't work correctly with path_info
>  	# unless we set the appropriate base URL
>  	if ($ENV{'PATH_INFO'}) {
> -		print "<base href=\"".esc_url($base_url)."\" />\n";
> +		print "<base href=\"".esc_url($base_url)."/\" />\n";

Doesn't this need to be somewhat conditional? Sites like repo.or.cz currently give <base href="/" /> presumably because $base_url for them is '/', and this change will make them show double slashes instead of a single one, no?

Previous: Daniel Abrecht
Message 2 of 2 in “gitweb: fix base url set if PATH_INFO is used, add a / at the end.”
  1. gitweb: fix base url set if PATH_INFO is used, add a / at the end.Daniel Abrecht, Feb 3, 2023
  2. Junio C HamanoFeb 6, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.