summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld2015-03-08 12:34:07 +0100
committerJason A. Donenfeld2015-03-09 17:42:02 +0100
commit8eef4589d0ba80fd4e6a9ce2f3ca4fcf266a64e0 (patch)
tree048296d0b760372a8f2eaf9ff8379c068e00411e
parent438bac6f579dab5b8f64e8ce42b88cfc3f053b28 (diff)
downloadcgit-8eef4589d0ba80fd4e6a9ce2f3ca4fcf266a64e0.tar.gz
ui-shared: currenturl should take into account leading slash
-rw-r--r--ui-shared.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 7bcb8d3..23a893b 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -69,7 +69,11 @@ const char *cgit_currenturl(void)
{
if (!ctx.qry.url)
return cgit_rooturl();
- return ctx.qry.url;
+ const char *root = cgit_rooturl();
+ size_t len = strlen(root);
+ if (len && root[len - 1] == '/')
+ return fmtalloc("%s%s", root, ctx.qry.url);
+ return fmtalloc("%s/%s", root, ctx.qry.url);
}
const char *cgit_rooturl(void)