Commit Diff


commit - 505e57644dd3f261aaf3165d7b0f79ef64c4bdea
commit + dd58c96158702b1ed23d36e9610a2381b2c07048
blob - 2f62cbe71384129f306fde0337eb666664302d3a
blob + 48ae81056315684ea93f56a951c8fbdf8be33440
--- fcgi.c
+++ fcgi.c
@@ -335,13 +335,7 @@ fcgi_parse_params(struct fcgi *fcgi, struct evbuffer *
 			path[vlen] = '\0';
 
 			free(clt->clt_script_name);
-			clt->clt_script_name = NULL;
-
-			if (vlen == 0 || path[vlen - 1] != '/')
-				asprintf(&clt->clt_script_name, "%s/", path);
-			else
-				clt->clt_script_name = strdup(path);
-
+			clt->clt_script_name = strdup(path);
 			if (clt->clt_script_name == NULL)
 				return (-1);
 
@@ -357,13 +351,7 @@ fcgi_parse_params(struct fcgi *fcgi, struct evbuffer *
 			path[vlen] = '\0';
 
 			free(clt->clt_path_info);
-			clt->clt_path_info = NULL;
-
-			if (*path != '/')
-				asprintf(&clt->clt_path_info, "/%s", path);
-			else
-				clt->clt_path_info = strdup(path);
-
+			clt->clt_path_info = strdup(path);
 			if (clt->clt_path_info == NULL)
 				return (-1);
 
blob - 5fc81c60cb360404cd9a82a51f6fd985e0aa49b3
blob + 1368577b708b800f5f7216dca6a9c9ab01cc0ad5
--- server.c
+++ server.c
@@ -341,9 +341,11 @@ route_home(struct env *env, struct client *clt)
 	if (clt_printf(clt, "Welcome to pkg_fcgi, the Gemini interface "
 	    "for the OpenBSD ports collection.\n\n") == -1)
 		return (-1);
-	if (clt_printf(clt, "=> /search Search for a package\n") == -1)
+	if (clt_printf(clt, "=> %s/search Search for a package\n",
+	    clt->clt_script_name) == -1)
 		return (-1);
-	if (clt_printf(clt, "=> /all/ All categories\n") == -1)
+	if (clt_printf(clt, "=> %s/all/ All categories\n",
+	    clt->clt_script_name) == -1)
 		return (-1);
 	if (clt_printf(clt, "\n") == -1)
 		return (-1);
@@ -414,9 +416,8 @@ route_search(struct env *env, struct client *clt)
 		comment = sqlite3_column_text(env->env_qsearch, 1);
 		fullpkgpath = sqlite3_column_text(env->env_qsearch, 2);
 
-		/* XXX fix URL */
-		if (clt_printf(clt, "=> /%s %s: %s\n", fullpkgpath,
-		    stem, comment) == -1)
+		if (clt_printf(clt, "=> %s/%s %s: %s\n", clt->clt_script_name,
+		    fullpkgpath, stem, comment) == -1)
 			goto err;
 	}
 
@@ -458,9 +459,8 @@ route_categories(struct env *env, struct client *clt)
 
 		fullpkgpath = sqlite3_column_text(env->env_qcats, 0);
 
-		/* XXX fix URL! */
-		if (clt_printf(clt, "=> /%s %s\n", fullpkgpath, fullpkgpath)
-		    == -1) {
+		if (clt_printf(clt, "=> %s/%s %s\n", clt->clt_script_name,
+		    fullpkgpath, fullpkgpath) == -1) {
 			sqlite3_reset(env->env_qcats);
 			return (-1);
 		}
@@ -511,9 +511,8 @@ route_listing(struct env *env, struct client *clt)
 
 		fullpkgpath = sqlite3_column_text(env->env_qbycat, 0);
 
-		/* XXX fix URL */
-		if (clt_printf(clt, "=> /%s %s\n", fullpkgpath, fullpkgpath)
-		    == -1) {
+		if (clt_printf(clt, "=> %s/%s %s\n", clt->clt_script_name,
+		    fullpkgpath, fullpkgpath) == -1) {
 			sqlite3_reset(env->env_qbycat);
 			return (-1);
 		}