diff options
-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 @@ | |||
17 | */ | 17 | */ |
18 | void cgit_parse_url(const char *url) | 18 | void cgit_parse_url(const char *url) |
19 | { | 19 | { |
20 | char *cmd, *p; | 20 | char *c, *cmd, *p; |
21 | struct cgit_repo *repo; | ||
21 | 22 | ||
22 | ctx.repo = NULL; | 23 | ctx.repo = NULL; |
23 | if (!url || url[0] == '\0') | 24 | if (!url || url[0] == '\0') |
@@ -29,16 +30,20 @@ void cgit_parse_url(const char *url) | |||
29 | return; | 30 | return; |
30 | } | 31 | } |
31 | 32 | ||
32 | cmd = strchr(url, '/'); | 33 | cmd = NULL; |
33 | while (!ctx.repo && cmd) { | 34 | c = strchr(url, '/'); |
34 | cmd[0] = '\0'; | 35 | while (c) { |
35 | ctx.repo = cgit_get_repoinfo(url); | 36 | c[0] = '\0'; |
36 | if (ctx.repo == NULL) { | 37 | repo = cgit_get_repoinfo(url); |
37 | cmd[0] = '/'; | 38 | if (repo) { |
38 | cmd = strchr(cmd + 1, '/'); | 39 | ctx.repo = repo; |
39 | continue; | 40 | cmd = c; |
40 | } | 41 | } |
42 | c[0] = '/'; | ||
43 | c = strchr(c + 1, '/'); | ||
44 | } | ||
41 | 45 | ||
46 | if (ctx.repo) { | ||
42 | ctx.qry.repo = ctx.repo->url; | 47 | ctx.qry.repo = ctx.repo->url; |
43 | p = strchr(cmd + 1, '/'); | 48 | p = strchr(cmd + 1, '/'); |
44 | if (p) { | 49 | if (p) { |