shithub: gemnine

Download patch

ref: 22965fbf81ab54511ca4fa66d4e4e597d373be42
parent: 3082e1e3d7333b0d4ade74f61c49af4069dde1f7
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon May 18 14:39:24 EDT 2020

urlto: fix relative when there is no / in the url at all

--- a/main.c
+++ b/main.c
@@ -55,11 +55,11 @@
 
 	/* relative, no scheme */
 	len = strlen(url->url);
-	if(url->url[len-1] == '/') /* easy */
-		u = smprint("%s/%s%s", url->url, u, trail);
-	else{
+	if(url->url[len-1] == '/'){ /* easy */
+		u = smprint("%s%s%s", url->url, u, trail);
+	}else{
 		/* replace the last element */
-		if((e = strrchr(url->url, '/')) != nil)
+		if((e = strrchr(url->url, '/')) != nil && e[-1] != '/')
 			len = e - url->url;
 		u = smprint("%.*s/%s%s", len, url->url, u, trail);
 	}