diff --git a/std/examples/chat/server.ts b/std/examples/chat/server.ts index 40affbd5f9..a86ed737a7 100644 --- a/std/examples/chat/server.ts +++ b/std/examples/chat/server.ts @@ -5,6 +5,7 @@ import { WebSocket, isWebSocketCloseEvent, } from "../../ws/mod.ts"; +import { fromFileUrl } from "../../path/mod.ts"; const clients = new Map(); let clientId = 0; @@ -47,7 +48,7 @@ listenAndServe({ port: 8080 }, async (req) => { }); } else { // server launched by deno run ./server.ts - const file = await Deno.open(u.pathname); + const file = await Deno.open(fromFileUrl(u)); req.respond({ status: 200, headers: new Headers({ diff --git a/std/examples/chat/server_test.ts b/std/examples/chat/server_test.ts index 74d4fefced..1aba4208ac 100644 --- a/std/examples/chat/server_test.ts +++ b/std/examples/chat/server_test.ts @@ -5,7 +5,7 @@ import { BufReader } from "../../io/bufio.ts"; import { connectWebSocket, WebSocket } from "../../ws/mod.ts"; import { delay } from "../../util/async.ts"; -const { test, build } = Deno; +const { test } = Deno; async function startServer(): Promise { const server = Deno.run({ @@ -26,12 +26,8 @@ async function startServer(): Promise { return server; } -// TODO: https://github.com/denoland/deno/issues/4108 -const ignore = build.os == "windows"; - test({ - ignore, - name: "GET / should serve html", + name: "[examples/chat] GET / should serve html", async fn() { const server = await startServer(); try { @@ -49,8 +45,7 @@ test({ }); test({ - ignore, - name: "GET /ws should upgrade conn to ws", + name: "[examples/chat] GET /ws should upgrade conn to ws", async fn() { const server = await startServer(); let ws: WebSocket | undefined; diff --git a/std/fs/expand_glob_test.ts b/std/fs/expand_glob_test.ts index 98abe0d732..4a1adc3089 100644 --- a/std/fs/expand_glob_test.ts +++ b/std/fs/expand_glob_test.ts @@ -2,11 +2,11 @@ const { cwd, execPath, run } = Deno; import { decode } from "../encoding/utf8.ts"; import { assert, assertEquals, assertStrContains } from "../testing/asserts.ts"; import { - isWindows, join, joinGlobs, normalize, relative, + fromFileUrl, } from "../path/mod.ts"; import { ExpandGlobOptions, @@ -39,13 +39,8 @@ async function expandGlobArray( return relativePaths; } -function urlToFilePath(url: URL): string { - // Since `new URL('file:///C:/a').pathname` is `/C:/a`, remove leading slash. - return url.pathname.slice(url.protocol == "file:" && isWindows ? 1 : 0); -} - const EG_OPTIONS: ExpandGlobOptions = { - root: urlToFilePath(new URL(join("testdata", "glob"), import.meta.url)), + root: fromFileUrl(new URL(join("testdata", "glob"), import.meta.url)), includeDirs: true, extended: false, globstar: false,