summaryrefslogtreecommitdiffabout
path: root/shared.c
authorLars Hjemli <hjemli@gmail.com>2007-09-19 22:56:53 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-09-19 22:56:53 (UTC)
commit4e40d8507ea9a3b5082ae690190e9d41c5b49ae2 (patch) (side-by-side diff)
tree119531367d7a5359ff62d1f050d9858d48b90179 /shared.c
parent0835ffefb8a1f5387463b22e2e5f7e34d387d7b1 (diff)
downloadcgit-4e40d8507ea9a3b5082ae690190e9d41c5b49ae2.zip
cgit-4e40d8507ea9a3b5082ae690190e9d41c5b49ae2.tar.gz
cgit-4e40d8507ea9a3b5082ae690190e9d41c5b49ae2.tar.bz2
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>
Diffstat (limited to 'shared.c') (more/less context) (ignore whitespace changes)
-rw-r--r--shared.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/shared.c b/shared.c
index 343a4f9..0fe513f 100644
--- a/shared.c
+++ b/shared.c
@@ -105,13 +105,13 @@ struct repoinfo *add_repo(const char *url)
cgit_repolist.repos = xrealloc(cgit_repolist.repos,
cgit_repolist.length *
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;
ret->owner = NULL;
ret->group = cgit_repo_group;
ret->defbranch = "master";
@@ -148,13 +148,13 @@ void cgit_global_config_cb(const char *name, const char *value)
cgit_index_header = xstrdup(value);
else if (!strcmp(name, "logo-link"))
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"))
cgit_snapshots = cgit_parse_snapshots_mask(value);
else if (!strcmp(name, "enable-index-links"))
cgit_enable_index_links = atoi(value);
@@ -186,13 +186,13 @@ void cgit_global_config_cb(const char *name, const char *value)
cgit_repo_group = xstrdup(value);
else if (!strcmp(name, "repo.url"))
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"))
cgit_repo->owner = xstrdup(value);
else if (cgit_repo && !strcmp(name, "repo.defbranch"))
cgit_repo->defbranch = xstrdup(value);