From b850d01991ee2c6e498182b6a758e8bc8b938307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=A8=E6=9D=89?= Date: Mon, 10 May 2021 21:29:26 +0800 Subject: [PATCH] fix(http/file_server): keep url and name consistent (#908) Add trailing slash to href on directories to match the name displayed on screen. --- http/file_server.ts | 2 +- http/file_server_test.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/http/file_server.ts b/http/file_server.ts index 191dd41b2435..a3f0edb33b9e 100644 --- a/http/file_server.ts +++ b/http/file_server.ts @@ -179,7 +179,7 @@ async function serveDir( mode: modeToString(entry.isDirectory, fileInfo.mode), size: entry.isFile ? fileLenToString(fileInfo.size ?? 0) : "", name: `${entry.name}${entry.isDirectory ? "/" : ""}`, - url: fileUrl, + url: `${fileUrl}${entry.isDirectory ? "/" : ""}`, }); } listEntry.sort((a, b) => diff --git a/http/file_server_test.ts b/http/file_server_test.ts index 307b8f680c00..97812887eef0 100644 --- a/http/file_server_test.ts +++ b/http/file_server_test.ts @@ -202,6 +202,7 @@ Deno.test("serveDirectory", async function () { assert(res.headers.has("access-control-allow-headers")); const page = await res.text(); assert(page.includes("README.md")); + assert(page.includes(`testdata/`)); // `Deno.FileInfo` is not completely compatible with Windows yet // TODO(bartlomieju): `mode` should work correctly in the future.