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

[PATCH] gitweb: Don't append '/' to project base URL if it ends with '/' or ':'

From
EBErik Broes <erikbroes@ripe.net>
Date
Apr 9, 2009, 19:59 UTC
Message-ID
<49DE5399.60402@ripe.net>

The base URL 'user@host' would always be appended with a '/', making it impossible to create clone URLs like: user@host:repo. Setting your base URL to 'user@host:' will now have the desired effect.

Signed-off-by: Erik Broes <erikbroes@ripe.net>
---
 gitweb/README      |   13 +++++++------
 gitweb/gitweb.perl |    5 ++++-
 2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/gitweb/README b/gitweb/README
index 8433dd1..efb0f1b 100644
--- a/gitweb/README
+++ b/gitweb/README
@@ -69,12 +69,13 @@ You can specify the following configuration variables when building GIT:
    SERVER_NAME CGI environment variable is not set (e.g. if running
    gitweb as standalone script).  [No default]
  * GITWEB_BASE_URL
-   Git base URLs used for URL to where fetch project from, i.e. full
-   URL is "$git_base_url/$project".  Shown on projects summary page.
-   Repository URL for project can be also configured per repository; this
-   takes precedence over URLs composed from base URL and a project name.
-   Note that you can setup multiple base URLs (for example one for
-   git:// protocol access, another for http:// access) from the gitweb
+   Git base URLs used for URL to where fetch project from, i.e. full URL is
+   "$git_base_url/$project".  No '/' will be added between the base URL and and
+   the project if the base URL ends with either a ':' or '/'.  Shown on
+   projects summary page.  Repository URL for project can be also configured
+   per repository; this takes precedence over URLs composed from base URL and a
+   project name.  Note that you can setup multiple base URLs (for example one
+   for git:// protocol access, another for http:// access) from the gitweb
    config file.  [No default]
  * GITWEB_CSS
    Points to the location where you put gitweb.css on your web server
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 33ef190..179c48d 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -4503,7 +4503,10 @@ sub git_summary {
 	# or make project git URL from git base URL and project name
 	my $url_tag = "URL";
 	my @url_list = git_get_project_url_list($project);
-	@url_list = map { "$_/$project" } @git_base_url_list unless @url_list;
+
+	# Only join with a '/' if there is no trailing '/' or ':'
+	@url_list = map { $_ .= '/' unless m{[:/]$}; $_.$project } @git_base_url_list unless @url_list;
+
 	foreach my $git_url (@url_list) {
 		next unless $git_url;
 		print "<tr class=\"metadata_url\"><td>$url_tag</td><td>$git_url</td></tr>\n";
-- 
1.6.2.1.519.gcf01bc
Message 1 of 1 in “gitweb: Don't append '/' to project base URL if it ends with '/' or ':'”
  1. gitweb: Don't append '/' to project base URL if it ends with '/' or ':'Erik Broes, Apr 9, 2009

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.