shithub: castor9

Download patch

ref: 04f3d56088d13e1b9853a4540530825f138e5ed4
parent: a26419bfecd8f5f3174b487c51c9552f8cde62fe
author: Julien Blanchard <[email protected]>
date: Thu Dec 31 08:56:01 EST 2020

Move base_url in url.c

--- a/castor.c
+++ b/castor.c
@@ -75,7 +75,6 @@
 };
 
 
-
 char*
 cleanup(char *line)
 {
@@ -284,24 +283,6 @@
 	}
 
 	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
--- a/castor.h
+++ b/castor.h
@@ -37,6 +37,7 @@
 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
--- a/url.c
+++ b/url.c
@@ -380,6 +380,24 @@
 	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)
 {