From 818a8010928cb8cef0b7043bd881c8cdce9b6efc Mon Sep 17 00:00:00 2001 From: River <22485304+actual-size@users.noreply.github.com> Date: Fri, 12 Jun 2020 02:36:20 +1000 Subject: feat: URL support in Deno filesystem methods (#5990) --- cli/js/ops/fs/open.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'cli/js/ops/fs/open.ts') diff --git a/cli/js/ops/fs/open.ts b/cli/js/ops/fs/open.ts index afe713db8..3742d0b52 100644 --- a/cli/js/ops/fs/open.ts +++ b/cli/js/ops/fs/open.ts @@ -1,5 +1,6 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { sendSync, sendAsync } from "../dispatch_json.ts"; +import { pathFromURL } from "../../util.ts"; export interface OpenOptions { read?: boolean; @@ -15,13 +16,18 @@ export interface OpenOptions { mode?: number; } -export function openSync(path: string, options: OpenOptions): number { +export function openSync(path: string | URL, options: OpenOptions): number { const mode: number | undefined = options?.mode; + path = pathFromURL(path); return sendSync("op_open", { path, options, mode }); } -export function open(path: string, options: OpenOptions): Promise { +export function open( + path: string | URL, + options: OpenOptions +): Promise { const mode: number | undefined = options?.mode; + path = pathFromURL(path); return sendAsync("op_open", { path, options, -- cgit v1.2.3