summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--ui-shared.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 4818e70..c23bc75 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -29,32 +29,37 @@ static char *http_date(time_t t)
29 29
30void cgit_print_error(char *msg) 30void cgit_print_error(char *msg)
31{ 31{
32 html("<div class='error'>"); 32 html("<div class='error'>");
33 html_txt(msg); 33 html_txt(msg);
34 html("</div>\n"); 34 html("</div>\n");
35} 35}
36 36
37char *cgit_hosturl() 37char *cgit_hosturl()
38{ 38{
39 char *host, *port; 39 char *host, *port;
40 40
41 host = getenv("HTTP_HOST");
42 if (host) {
43 host = xstrdup(host);
44 } else {
41 host = getenv("SERVER_NAME"); 45 host = getenv("SERVER_NAME");
42 if (!host) 46 if (!host)
43 return NULL; 47 return NULL;
44 port = getenv("SERVER_PORT"); 48 port = getenv("SERVER_PORT");
45 if (port && atoi(port) != 80) 49 if (port && atoi(port) != 80)
46 host = xstrdup(fmt("%s:%d", host, atoi(port))); 50 host = xstrdup(fmt("%s:%d", host, atoi(port)));
47 else 51 else
48 host = xstrdup(host); 52 host = xstrdup(host);
53 }
49 return host; 54 return host;
50} 55}
51 56
52char *cgit_rooturl() 57char *cgit_rooturl()
53{ 58{
54 if (ctx.cfg.virtual_root) 59 if (ctx.cfg.virtual_root)
55 return fmt("%s/", ctx.cfg.virtual_root); 60 return fmt("%s/", ctx.cfg.virtual_root);
56 else 61 else
57 return ctx.cfg.script_name; 62 return ctx.cfg.script_name;
58} 63}
59 64
60char *cgit_repourl(const char *reponame) 65char *cgit_repourl(const char *reponame)