From 04f3d56088d13e1b9853a4540530825f138e5ed4 Mon Sep 17 00:00:00 2001 From: Julien Blanchard Date: Thu, 31 Dec 2020 13:56:01 +0000 Subject: [PATCH] Move base_url in url.c --- castor.c | 19 ------------------- castor.h | 1 + url.c | 18 ++++++++++++++++++ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/castor.c b/castor.c index fadca08..8a0c150 100644 --- a/castor.c +++ b/castor.c @@ -75,7 +75,6 @@ char *menu3[] = { }; - char* cleanup(char *line) { @@ -286,24 +285,6 @@ render_link(Ctx *c, char *line) plrtstr(&c->text, 1000000, 8, 0, font, strdup(label), PL_HOT, estrdup(link)); } -Url* -base_url(Url *url) -{ - char *base_url, *path, *ptr; - - if(url->path == "/" || url->path == NULL){ - path = "/"; - }else{ - path = estrdup(url->path); - ptr = strrchr(path, '/'); - if(path[strlen(path)-1] != '/') - strcpy(ptr, "/"); - } - base_url = smprint("gemini://%s%s", url->host, path); - - return urlparse(nil, base_url); -} - int request(Url *url) { diff --git a/castor.h b/castor.h index 0dab16f..8c72a36 100644 --- a/castor.h +++ b/castor.h @@ -37,6 +37,7 @@ int Nfmt(Fmt*); int Mfmt(Fmt*); int Ufmt(Fmt *f); Url *urlparse(Url *from, char *s); +Url *base_url(Url *u); int matchurl(Url *u, Url *s); void freeurl(Url *u); char *Upath(Url *u); \ No newline at end of file diff --git a/url.c b/url.c index a8ea392..d1975b3 100644 --- a/url.c +++ b/url.c @@ -380,6 +380,24 @@ Out: return u; } +Url* +base_url(Url *url) +{ + char *base_url, *path, *ptr; + + if(url->path == "/" || url->path == nil){ + path = "/"; + }else{ + path = estrdup(url->path); + ptr = strrchr(path, '/'); + if(path[strlen(path)-1] != '/') + strcpy(ptr, "/"); + } + base_url = smprint("gemini://%s%s", url->host, path); + + return urlparse(nil, base_url); +} + int matchurl(Url *u, Url *s) { -- 2.45.2