Diff options
Diffstat (limited to '')
-rw-r--r--source/cgit.c11
-rw-r--r--source/cgit.h1
2 files changed, 5 insertions, 7 deletions
diff --git a/source/cgit.c b/source/cgit.c
index eaf1d19..715db59 100644
--- a/source/cgit.c
+++ b/source/cgit.c
@@ -91,6 +91,8 @@ static NORETURN void die_routine(const char *msg, va_list params)
static void prepare_context(void)
{
+ const char *script_name = getenv("SCRIPT_NAME");
+
memset(&ctx, 0, sizeof(ctx));
ctx.cfg.agefile = "info/web/last-modified";
ctx.cfg.cache_size = 0;
@@ -155,7 +157,6 @@ static void prepare_context(void)
ctx.env.path_info = getenv("PATH_INFO");
ctx.env.query_string = getenv("QUERY_STRING");
ctx.env.request_method = getenv("REQUEST_METHOD");
- ctx.env.script_name = getenv("SCRIPT_NAME");
ctx.env.server_name = getenv("SERVER_NAME");
ctx.env.server_port = getenv("SERVER_PORT");
ctx.env.http_cookie = getenv("HTTP_COOKIE");
@@ -168,8 +169,9 @@ static void prepare_context(void)
ctx.page.filename = NULL;
ctx.page.size = 0;
string_list_init_dup(&ctx.cfg.mimetypes);
- if (ctx.env.script_name)
- ctx.cfg.script_name = xstrdup(ctx.env.script_name);
+ if (script_name)
+ ctx.cfg.script_name = xstrdup(script_name);
+ ctx.cfg.virtual_root = cgit_ensure_end(ctx.cfg.script_name, '/');
if (ctx.env.query_string)
ctx.qry.raw = xstrdup(ctx.env.query_string);
if (!ctx.env.cgit_config)
@@ -1349,9 +1351,6 @@ int cmd_main(int argc, const char **argv)
ctx.repo = NULL;
http_parse_querystring(ctx.qry.raw, apply_query_param);
- if (!ctx.cfg.virtual_root && ctx.cfg.script_name)
- ctx.cfg.virtual_root = cgit_ensure_end(ctx.cfg.script_name, '/');
-
// Falling back to PATH_INFO lets cgit serve virtual urls without a
// rewrite rule in the web server, and folding it into the raw query
// string keeps it part of the cache key.
diff --git a/source/cgit.h b/source/cgit.h
index 5e17a3e..a089633 100644
--- a/source/cgit.h
+++ b/source/cgit.h
@@ -303,7 +303,6 @@ struct cgit_environment {
const char *path_info;
const char *query_string;
const char *request_method;
- const char *script_name;
const char *server_name;
const char *server_port;
const char *http_cookie;