diff options
author | Julian Maurice <julian.maurice@biblibre.com> | 2014-03-28 23:18:29 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2014-04-05 19:05:36 -0300 |
commit | 10451797fa2370aab6f4146c86e0fa939a9a982b (patch) | |
tree | 3fb006eb4c87b9777032db53040d923ff3794340 | |
parent | Makefile: use more reliable git tarball mirror (diff) | |
download | cgit-pink-10451797fa2370aab6f4146c86e0fa939a9a982b.tar.gz cgit-pink-10451797fa2370aab6f4146c86e0fa939a9a982b.zip |
Fix cgit_parse_url when a repo url is contained in another repo url
For example, if I have two repos (remove-suffix is enabled): /foo /foo/bar http://cgit/foo/bar/ is interpreted as "repository 'foo', command 'bar'" instead of "repository 'foo/bar'"
Diffstat (limited to '')
-rw-r--r-- | parsing.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/parsing.c b/parsing.c index 599f61e..5b4b1f4 100644 --- a/parsing.c +++ b/parsing.c @@ -17,7 +17,8 @@ */ void cgit_parse_url(const char *url) { - char *cmd, *p; + char *c, *cmd, *p; + struct cgit_repo *repo; ctx.repo = NULL; if (!url || url[0] == '\0') @@ -29,16 +30,20 @@ void cgit_parse_url(const char *url) return; } - cmd = strchr(url, '/'); - while (!ctx.repo && cmd) { - cmd[0] = '\0'; - ctx.repo = cgit_get_repoinfo(url); - if (ctx.repo == NULL) { - cmd[0] = '/'; - cmd = strchr(cmd + 1, '/'); - continue; + cmd = NULL; + c = strchr(url, '/'); + while (c) { + c[0] = '\0'; + repo = cgit_get_repoinfo(url); + if (repo) { + ctx.repo = repo; + cmd = c; } + c[0] = '/'; + c = strchr(c + 1, '/'); + } + if (ctx.repo) { ctx.qry.repo = ctx.repo->url; p = strchr(cmd + 1, '/'); if (p) { |