diff options
| author | Yuqing Chen <mr.chenyuqing@live.com> | 2019-05-23 06:58:20 +0800 |
|---|---|---|
| committer | Bert Belder <bertbelder@gmail.com> | 2019-05-22 15:58:20 -0700 |
| commit | e2debab359f2e07b6a784fbc50df31e39a4cba29 (patch) | |
| tree | d2b2c6c461023906ff747b230b45a91f61179eee | |
| parent | de713ea871aee8effdafd7e976f6d409eb52efac (diff) | |
fix(fileserver): wrong url href of displayed files (denoland/deno_std#426)
Original: https://github.com/denoland/deno_std/commit/be6cd35cbf65ef49b15bf0faf1e582d79f5a0f87
| -rwxr-xr-x | http/file_server.ts | 2 | ||||
| -rw-r--r-- | http/file_server_test.ts | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/http/file_server.ts b/http/file_server.ts index 21482e747..5ef891aa8 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 38071d3e4..578b0e624 100644 --- a/http/file_server_test.ts +++ b/http/file_server_test.ts @@ -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(); } |
