diff options
author | Ali Hasani <a.hassssani@gmail.com> | 2020-05-03 23:44:38 +0430 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-03 15:14:38 -0400 |
commit | 5cc0f056d1af6f76c6ad81a6cd68dcaabba60f35 (patch) | |
tree | 4a32cb418ca84aba47e05e6dc6c98e8ef724fcd0 /std/node/_fs/_fs_readlink.ts | |
parent | 7e32269f3f230c5b714bbf70aa59d74f9a867373 (diff) |
[std/node] add the ability to path argument to be URL type (#5055)
Diffstat (limited to 'std/node/_fs/_fs_readlink.ts')
-rw-r--r-- | std/node/_fs/_fs_readlink.ts | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/std/node/_fs/_fs_readlink.ts b/std/node/_fs/_fs_readlink.ts index b32cd9dd3..d461cf390 100644 --- a/std/node/_fs/_fs_readlink.ts +++ b/std/node/_fs/_fs_readlink.ts @@ -4,6 +4,7 @@ import { MaybeEmpty, notImplemented, } from "../_utils.ts"; +import { fromFileUrl } from "../path.ts"; const { readLink: denoReadlink, readLinkSync: denoReadlinkSync } = Deno; @@ -49,10 +50,12 @@ function getEncoding( } export function readlink( - path: string, + path: string | URL, optOrCallback: ReadlinkCallback | ReadlinkOptions, callback?: ReadlinkCallback ): void { + path = path instanceof URL ? fromFileUrl(path) : path; + let cb: ReadlinkCallback | undefined; if (typeof optOrCallback === "function") { cb = optOrCallback; @@ -71,8 +74,10 @@ export function readlink( } export function readlinkSync( - path: string, + path: string | URL, opt?: ReadlinkOptions ): string | Uint8Array { + path = path instanceof URL ? fromFileUrl(path) : path; + return maybeEncode(denoReadlinkSync(path), getEncoding(opt)); } |