ref: a38c9ea785ebf36491f5fa5e3e7cb3745ca2731c
parent: c2dacd29756de342a20be49414e0fdbce3af9a9d
author: Sigrid Haflínudóttir <[email protected]>
date: Sun May 17 16:21:35 EDT 2020
fix absolute vs relative urls
--- a/main.c
+++ b/main.c
@@ -222,10 +222,13 @@
while(isspace(*t))
t++;
u = t;
- if((t = strpbrk(t, " :/")) == nil || t[0] != ':' || t[1] != '/' || t[2] != '/'){ /* relative URL */
- if(*u == '/')
- u++;
- Bprint(&out, "=> gemini://%s:%s/%s\n", r->url->server, r->url->port, u);
+ if((t = strpbrk(t, " :/")) == nil || t[0] != ':' || t[1] != '/' || t[2] != '/'){ /* no scheme */
+ if(*u == '/'){ /* absolute */
+ Bprint(&out, "=> gemini://%s:%s/%s\n", r->url->server, r->url->port, u+1);
+ }else{
+ len = strlen(r->url->url);
+ Bprint(&out, "=> %s%s%s\n", r->url->url, r->url->url[len-1] != '/' ? "/" : "", u);
+ }
}else{
Bprint(&out, "%s\n", s);
}