Skip to content

Commit

Permalink
fix(fileserver): wrong url href of displayed files (denoland/std#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuqingc authored and piscisaureus committed May 22, 2019
1 parent de713ea commit e2debab
Show file tree
Hide file tree
Showing 2 changed files with 13 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 @@ -162,7 +162,7 @@ async function serveDir(
listEntry.push(
createDirEntryDisplay(
info.name,
fn,
fn.replace(currentDir, ""),
info.isFile() ? info.len : null,
mode,
info.isDirectory()
Expand Down
12 changes: 12 additions & 0 deletions http/file_server_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ test(async function serveDirectory(): Promise<void> {
assert(res.headers.has("access-control-allow-headers"));
const page = await res.text();
assert(page.includes("azure-pipelines.yml"));

// `Deno.FileInfo` is not completely compatible with Windows yet
// TODO: `mode` should work correctly in the future. Correct this test case accordingly.
Deno.platform.os !== "win" &&
assert(/<td class="mode">\([a-zA-Z-]{10}\)<\/td>/.test(page));
Deno.platform.os === "win" &&
assert(/<td class="mode">\(unknown mode\)<\/td>/.test(page));
assert(
page.includes(
`<td><a href="/azure-pipelines.yml">azure-pipelines.yml</a></td>`
)
);
} finally {
killFileServer();
}
Expand Down

0 comments on commit e2debab

Please sign in to comment.