Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: disable URL.createObjectUrl #7543

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 4 additions & 28 deletions cli/rt/11_url.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

((window) => {
const core = window.Deno.core;
const { getRandomValues } = window.__bootstrap.crypto;
const { customInspect } = window.__bootstrap.console;
const { isIterable, requiredArguments } = window.__bootstrap.webUtil;

Expand Down Expand Up @@ -385,14 +384,6 @@
return parts;
}

// Based on https://github.com/kelektiv/node-uuid
// TODO(kevinkassimo): Use deno_std version once possible.
function generateUUID() {
return "00000000-0000-4000-8000-000000000000".replace(/[0]/g, () =>
// random integer from 0 to 15 as a hex digit.
(getRandomValues(new Uint8Array(1))[0] % 16).toString(16));
}

// Keep it outside of URL to avoid any attempts of access.
const blobURLMap = new Map();

Expand Down Expand Up @@ -712,27 +703,12 @@
return this.href;
}

// TODO(kevinkassimo): implement MediaSource version in the future.
static createObjectURL(blob) {
const origin = "http://deno-opaque-origin";
const key = `blob:${origin}/${generateUUID()}`;
blobURLMap.set(key, blob);
return key;
static createObjectURL() {
throw new Error("Not implemented");
}

static revokeObjectURL(url) {
let urlObject;
try {
urlObject = new URL(url);
} catch {
throw new TypeError("Provided URL string is not valid");
}
if (urlObject.protocol !== "blob:") {
return;
}
// Origin match check seems irrelevant for now, unless we implement
// persisten storage for per globalThis.location.origin at some point.
blobURLMap.delete(url);
static revokeObjectURL() {
throw new Error("Not implemented");
}
}

Expand Down