summaryrefslogtreecommitdiff
path: root/std/node/_fs/_fs_readlink.ts
diff options
context:
space:
mode:
Diffstat (limited to 'std/node/_fs/_fs_readlink.ts')
-rw-r--r--std/node/_fs/_fs_readlink.ts9
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));
}