Skip to content

Commit

Permalink
fix(http/file_server): use platform specific resolve
Browse files Browse the repository at this point in the history
On Windows, running `posix.resolve("C:\\Users\\abc")` within
`C:\Users\abc\Desktop\folderabc` would resolve to
`C:\Users\abc\Desktop\folderabc/C:\Users\abc` which is not expected.
  • Loading branch information
Chocobo1 committed Jun 4, 2023
1 parent 2d9dd29 commit 7804930
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions http/file_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @module
*/

import { extname, posix } from "../path/mod.ts";
import { extname, posix, resolve } from "../path/mod.ts";
import { contentType } from "../media_types/content_type.ts";
import { serve, serveTls } from "./server.ts";
import { calculate, ifNoneMatch } from "./etag.ts";
Expand Down Expand Up @@ -744,7 +744,7 @@ function main() {
}

const wild = serverArgs._ as string[];
const target = posix.resolve(wild[0] ?? "");
const target = resolve(wild[0] ?? "");

Check warning on line 747 in http/file_server.ts

View check run for this annotation

Codecov / codecov/patch

http/file_server.ts#L747

Added line #L747 was not covered by tests

const handler = (req: Request): Promise<Response> => {
return serveDir(req, {
Expand Down

0 comments on commit 7804930

Please sign in to comment.