From fb52dfe4197457eb5eb4134dece22ad42752f31e Mon Sep 17 00:00:00 2001 From: Julien Blanchard Date: Tue, 22 Dec 2020 11:51:02 +0000 Subject: [PATCH] Add some comments before refact --- castor.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/castor.c b/castor.c index 3eacf84..b40e8c2 100644 --- a/castor.c +++ b/castor.c @@ -602,19 +602,24 @@ texthit(Panel *p, int b, Rtext *rt) if(link==nil) return; - if(strbeg(link, "gemini://") == 0){ + if(strbeg(link, "gemini://") == 0){ /* gemini absolute */ next_url = urlparse(nil, link); - }else if(strbeg(link, "//") == 0){ + }else if(strstr(link, "://") != 0){ /* other protocol absolute */ + next_url = urlparse(nil, link); + }else if(strbeg(link, "//") == 0){ /* schemeless so gemini */ next_url = urlparse(nil, smprint("gemini:%s", link)); - }else if(strbeg(link, "mailto:") == 0){ + }else if(strbeg(link, "mailto:") == 0){ /* mailto: */ next_url = urlparse(nil, link); }else{ /* assuming relative URL */ if(strcmp(link, "/") == 0){ + /* no slash, must be a hostname */ n = smprint("gemini://%s", current_base_url->host); }else if(*link == '/'){ + /* start with a slash so skip it (+1) */ n = smprint("%s%s", urlparse(current_base_url, link)->raw, estrdup(link)+1); }else{ + /* make an absolute URL of the link */ n = smprint("%s%s", urlparse(current_base_url, link)->raw, estrdup(link)); } next_url = urlparse(nil, n); -- 2.45.2