diff options
Diffstat (limited to 'ext/web/09_file.js')
-rw-r--r-- | ext/web/09_file.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/ext/web/09_file.js b/ext/web/09_file.js index a81176b38..d65a512f9 100644 --- a/ext/web/09_file.js +++ b/ext/web/09_file.js @@ -14,6 +14,7 @@ const core = globalThis.Deno.core; const ops = core.ops; import * as webidl from "ext:deno_webidl/00_webidl.js"; import { ReadableStream } from "ext:deno_web/06_streams.js"; +import { URL } from "ext:deno_url/00_url.js"; const primordials = globalThis.__bootstrap.primordials; const { ArrayBufferPrototype, @@ -653,6 +654,33 @@ function blobFromObjectUrl(url) { return blob; } +/** + * @param {Blob} blob + * @returns {string} + */ +function createObjectURL(blob) { + const prefix = "Failed to execute 'createObjectURL' on 'URL'"; + webidl.requiredArguments(arguments.length, 1, prefix); + blob = webidl.converters["Blob"](blob, prefix, "Argument 1"); + + return ops.op_blob_create_object_url(blob.type, getParts(blob)); +} + +/** + * @param {string} url + * @returns {void} + */ +function revokeObjectURL(url) { + const prefix = "Failed to execute 'revokeObjectURL' on 'URL'"; + webidl.requiredArguments(arguments.length, 1, prefix); + url = webidl.converters["DOMString"](url, prefix, "Argument 1"); + + ops.op_blob_revoke_object_url(url); +} + +URL.createObjectURL = createObjectURL; +URL.revokeObjectURL = revokeObjectURL; + export { Blob, blobFromObjectUrl, |