diff options
Diffstat (limited to 'std/node/_fs/_fs_readFile.ts')
-rw-r--r-- | std/node/_fs/_fs_readFile.ts | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/std/node/_fs/_fs_readFile.ts b/std/node/_fs/_fs_readFile.ts index 13e82bfe1..8d3c96db0 100644 --- a/std/node/_fs/_fs_readFile.ts +++ b/std/node/_fs/_fs_readFile.ts @@ -5,6 +5,7 @@ import { intoCallbackAPIWithIntercept, MaybeEmpty, } from "../_utils.ts"; +import { fromFileUrl } from "../path.ts"; const { readFile: denoReadFile, readFileSync: denoReadFileSync } = Deno; @@ -51,10 +52,11 @@ function maybeDecode( } export function readFile( - path: string, + path: string | URL, optOrCallback: ReadFileCallback | ReadFileOptions, callback?: ReadFileCallback ): void { + path = path instanceof URL ? fromFileUrl(path) : path; let cb: ReadFileCallback | undefined; if (typeof optOrCallback === "function") { cb = optOrCallback; @@ -73,8 +75,9 @@ export function readFile( } export function readFileSync( - path: string, + path: string | URL, opt?: ReadFileOptions ): string | Uint8Array { + path = path instanceof URL ? fromFileUrl(path) : path; return maybeDecode(denoReadFileSync(path), getEncoding(opt)); } |