~julienxx/castor9

04f3d56088d13e1b9853a4540530825f138e5ed4 — Julien Blanchard 3 years ago a26419b
Move base_url in url.c
3 files changed, 19 insertions(+), 19 deletions(-)

M castor.c
M castor.h
M url.c
M castor.c => castor.c +0 -19
@@ 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)
{

M castor.h => castor.h +1 -0
@@ 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

M url.c => url.c +18 -0
@@ 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)
{