diff options
Diffstat (limited to 'source/cmd.c')
| -rw-r--r-- | source/cmd.c | 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 16 insertions, 27 deletions
diff --git a/source/cmd.c b/source/cmd.c index 49c1eb4..08de123 100644 --- a/source/cmd.c +++ b/source/cmd.c @@ -34,39 +34,28 @@ static void head_fn(void) static void about_fn(void) { - char *currenturl, *query, *redirect; - size_t path_info_len; + char *query, *summary; + // The page shows the readme alone, and the readme's links lead into + // the tree, so nothing lives below it. + if (ctx.qry.path) { + cgit_print_error_page(404, "Not Found", "Not found"); + return; + } if (!ctx.repo) { cgit_print_site_readme(); return; } - - // The about page resolves relative links against its own URL, so it - // only works with a trailing slash. The branch and the rest of the - // query travel along with either redirect. - path_info_len = ctx.env.path_info ? strlen(ctx.env.path_info) : 0; - if (!ctx.qry.path && - (!ctx.qry.url || !*ctx.qry.url || ctx.qry.url[strlen(ctx.qry.url) - 1] != '/') && - (!path_info_len || ctx.env.path_info[path_info_len - 1] != '/')) { - currenturl = cgit_currenturl(); - query = cgit_currentquery(); - redirect = cgit_fmtalloc("%s/", currenturl); - cgit_redirect(redirect, query, true); - free(currenturl); - free(query); - free(redirect); - } else if (ctx.repo->readme.nr) { - cgit_print_repo_readme(ctx.qry.path); - } else { - currenturl = cgit_currenturl(); - query = cgit_currentquery(); - redirect = cgit_fmtalloc("%s../", currenturl); - cgit_redirect(redirect, query, false); - free(currenturl); - free(query); - free(redirect); + if (ctx.repo->readme.nr) { + cgit_print_repo_readme(); + return; } + // The branch and the rest of the query travel along to the summary. + query = cgit_currentquery(); + summary = cgit_repourl(ctx.repo->url); + cgit_redirect(summary, query, false); + free(query); + free(summary); } static void atom_fn(void) |
