Skip to content

Commit

Permalink
fix(http/file_server): keep url and name consistent (#908)
Browse files Browse the repository at this point in the history
Add trailing slash to href on directories to match the name displayed on screen.
  • Loading branch information
zhmushan authored May 10, 2021
1 parent 69183a0 commit b850d01
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion http/file_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
1 change: 1 addition & 0 deletions http/file_server_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(`<a href="/testdata/">testdata/</a>`));

// `Deno.FileInfo` is not completely compatible with Windows yet
// TODO(bartlomieju): `mode` should work correctly in the future.
Expand Down

0 comments on commit b850d01

Please sign in to comment.