mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 14:30:02 -04:00
unrewriteBlob parity
This commit is contained in:
parent
dc0a2c6d12
commit
3100d07609
3 changed files with 22 additions and 8 deletions
|
@ -1,7 +1,12 @@
|
|||
import { SCRAMJETCLIENT } from "../../symbols";
|
||||
import { ScramjetClient } from "../client";
|
||||
import { nativeGetOwnPropertyDescriptor } from "../natives";
|
||||
import { unrewriteUrl, htmlRules, unrewriteHtml } from "../../shared";
|
||||
import {
|
||||
unrewriteUrl,
|
||||
htmlRules,
|
||||
unrewriteHtml,
|
||||
unrewriteBlob,
|
||||
} from "../../shared";
|
||||
import {
|
||||
rewriteUrl,
|
||||
rewriteCss,
|
||||
|
@ -71,8 +76,8 @@ export default function (client: ScramjetClient, self: typeof window) {
|
|||
["src", "data", "href", "action", "formaction"].includes(attr)
|
||||
) {
|
||||
if (element === HTMLMediaElement && value.startsWith("blob:")) {
|
||||
let origin = new URL(value.substring("blob:".length));
|
||||
value = "blob:" + location.origin + origin.pathname;
|
||||
// mediasource blobs cannot be handled in the service worker and must be sourced here
|
||||
value = unrewriteBlob(value);
|
||||
} else {
|
||||
value = rewriteUrl(value, client.meta);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import { URLMeta, rewriteUrl } from "./url";
|
|||
import { rewriteCss } from "./css";
|
||||
import { rewriteJs } from "./js";
|
||||
import { CookieStore } from "../cookie";
|
||||
import { unrewriteBlob } from "../../shared";
|
||||
|
||||
export function rewriteHtml(
|
||||
html: string,
|
||||
|
@ -120,8 +121,6 @@ export const htmlRules: {
|
|||
"image",
|
||||
"iframe",
|
||||
"source",
|
||||
"video",
|
||||
"audio",
|
||||
"input",
|
||||
"track",
|
||||
],
|
||||
|
@ -132,6 +131,17 @@ export const htmlRules: {
|
|||
poster: ["video"],
|
||||
"xlink:href": ["image"],
|
||||
},
|
||||
{
|
||||
fn: (value: string, meta: URLMeta) => {
|
||||
if (value.startsWith("blob:")) {
|
||||
// for media elements specifically they must take the original blob
|
||||
// because they can't be fetch'd
|
||||
return unrewriteBlob(value);
|
||||
}
|
||||
return rewriteUrl(value, meta);
|
||||
},
|
||||
src: ["video", "audio"],
|
||||
},
|
||||
{
|
||||
fn: () => null,
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import {
|
|||
rewriteHtml,
|
||||
rewriteJs,
|
||||
rewriteWorkers,
|
||||
unrewriteBlob,
|
||||
} from "../shared";
|
||||
|
||||
import type { URLMeta } from "../shared/rewriters/url";
|
||||
|
@ -53,9 +54,7 @@ export async function swfetch(
|
|||
) {
|
||||
let dataurl = requesturl.pathname.substring(this.config.prefix.length);
|
||||
if (dataurl.startsWith("blob:")) {
|
||||
let origin = new URL(dataurl.substring("blob:".length));
|
||||
dataurl = "blob:" + location.origin + origin.pathname;
|
||||
console.log(dataurl);
|
||||
dataurl = unrewriteBlob(dataurl);
|
||||
}
|
||||
|
||||
let response: Response = await fetch(dataurl, {});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue