From e2debab359f2e07b6a784fbc50df31e39a4cba29 Mon Sep 17 00:00:00 2001 From: Yuqing Chen Date: Thu, 23 May 2019 06:58:20 +0800 Subject: [PATCH] fix(fileserver): wrong url href of displayed files (denoland/deno_std#426) Original: https://github.com/denoland/deno_std/commit/be6cd35cbf65ef49b15bf0faf1e582d79f5a0f87 --- http/file_server.ts | 2 +- http/file_server_test.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/http/file_server.ts b/http/file_server.ts index 21482e747072ea..5ef891aa84fbb8 100755 --- a/http/file_server.ts +++ b/http/file_server.ts @@ -162,7 +162,7 @@ async function serveDir( listEntry.push( createDirEntryDisplay( info.name, - fn, + fn.replace(currentDir, ""), info.isFile() ? info.len : null, mode, info.isDirectory() diff --git a/http/file_server_test.ts b/http/file_server_test.ts index 38071d3e4bd7b3..578b0e6241e79e 100644 --- a/http/file_server_test.ts +++ b/http/file_server_test.ts @@ -56,6 +56,18 @@ test(async function serveDirectory(): Promise { 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(/\([a-zA-Z-]{10}\)<\/td>/.test(page)); + Deno.platform.os === "win" && + assert(/\(unknown mode\)<\/td>/.test(page)); + assert( + page.includes( + `azure-pipelines.yml` + ) + ); } finally { killFileServer(); }