cgit

commit 4e40d8507ea9a3b5082ae690190e9d41c5b49ae2

Author: Lars Hjemli <hjemli@gmail.com>

Use trim_end() to remove trailing slashes

All urls and paths read from cgitrc needs to be 'normalized', i.e. get any
trailing slashes removed, and the trim_end() function works out nice for
this purpose.

Removing the trailing slashes also happens to fix the case where the virtual
root should be a single slash; that case used to require specifying the full
hostname (including the http:// prefix), but now it can simply be specified
as /.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>

 shared.c | 6 +++---


diff --git a/shared.c b/shared.c
index 343a4f93f2698ed5df50276a2eb72a40e68c9597..0fe513f4f24efc7796d3627e7743e952e323ed35 100644
--- a/shared.c
+++ b/shared.c
@@ -108,7 +108,7 @@ 					       sizeof(struct repoinfo));
 	}
 
 	ret = &cgit_repolist.repos[cgit_repolist.count-1];
-	ret->url = xstrdup(url);
+	ret->url = trim_end(url, '/');
 	ret->name = ret->url;
 	ret->path = NULL;
 	ret->desc = NULL;
@@ -151,7 +151,7 @@ 		cgit_logo_link = xstrdup(value);
 	else if (!strcmp(name, "module-link"))
 		cgit_module_link = xstrdup(value);
 	else if (!strcmp(name, "virtual-root"))
-		cgit_virtual_root = xstrdup(value);
+		cgit_virtual_root = trim_end(value, '/');
 	else if (!strcmp(name, "nocache"))
 		cgit_nocache = atoi(value);
 	else if (!strcmp(name, "snapshots"))
@@ -189,7 +189,7 @@ 		cgit_repo = add_repo(value);
 	else if (!strcmp(name, "repo.name"))
 		cgit_repo->name = xstrdup(value);
 	else if (cgit_repo && !strcmp(name, "repo.path"))
-		cgit_repo->path = xstrdup(value);
+		cgit_repo->path = trim_end(value, '/');
 	else if (cgit_repo && !strcmp(name, "repo.desc"))
 		cgit_repo->desc = xstrdup(value);
 	else if (cgit_repo && !strcmp(name, "repo.owner"))