瀏覽代碼

Merge pull request #690 from albertino80/fix_relative_urls

fix relative url in directory listing
bel2125 6 年之前
父節點
當前提交
5a8fd381d4
共有 1 個文件被更改,包括 14 次插入16 次删除
  1. 14 16
      src/civetweb.c

+ 14 - 16
src/civetweb.c

@@ -9083,15 +9083,14 @@ print_dir_entry(struct de *de)
 	}
 	}
 	mg_url_encode(de->file_name, href, hrefsize);
 	mg_url_encode(de->file_name, href, hrefsize);
 	mg_printf(de->conn,
 	mg_printf(de->conn,
-	          "<tr><td><a href=\"%s%s%s\">%s%s</a></td>"
-	          "<td>&nbsp;%s</td><td>&nbsp;&nbsp;%s</td></tr>\n",
-	          de->conn->request_info.local_uri,
-	          href,
-	          de->file.is_directory ? "/" : "",
-	          de->file_name,
-	          de->file.is_directory ? "/" : "",
-	          mod,
-	          size);
+              "<tr><td><a href=\"%s%s\">%s%s</a></td>"
+              "<td>&nbsp;%s</td><td>&nbsp;&nbsp;%s</td></tr>\n",
+              href,
+              de->file.is_directory ? "/" : "",
+              de->file_name,
+              de->file.is_directory ? "/" : "",
+              mod,
+              size);
 	mg_free(href);
 	mg_free(href);
 	return 0;
 	return 0;
 }
 }
@@ -9373,13 +9372,12 @@ handle_directory_request(struct mg_connection *conn, const char *dir)
 
 
 	/* Print first entry - link to a parent directory */
 	/* Print first entry - link to a parent directory */
 	mg_printf(conn,
 	mg_printf(conn,
-	          "<tr><td><a href=\"%s%s\">%s</a></td>"
-	          "<td>&nbsp;%s</td><td>&nbsp;&nbsp;%s</td></tr>\n",
-	          conn->request_info.local_uri,
-	          "..",
-	          "Parent directory",
-	          "-",
-	          "-");
+              "<tr><td><a href=\"%s\">%s</a></td>"
+              "<td>&nbsp;%s</td><td>&nbsp;&nbsp;%s</td></tr>\n",
+              "..",
+              "Parent directory",
+              "-",
+              "-");
 
 
 	/* Sort and print directory entries */
 	/* Sort and print directory entries */
 	if (data.entries != NULL) {
 	if (data.entries != NULL) {