1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-29 16:30:56 -05:00

fix(fileserver): wrong url href of displayed files (denoland/deno_std#426)

Original: be6cd35cbf
This commit is contained in:
Yuqing Chen 2019-05-23 06:58:20 +08:00 committed by Bert Belder
parent de713ea871
commit e2debab359
2 changed files with 13 additions and 1 deletions

View file

@ -162,7 +162,7 @@ async function serveDir(
listEntry.push(
createDirEntryDisplay(
info.name,
fn,
fn.replace(currentDir, ""),
info.isFile() ? info.len : null,
mode,
info.isDirectory()

View file

@ -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();
}