diff --git a/src/client/shared/opfs.ts b/src/client/shared/opfs.ts index 33f400e..81744f3 100644 --- a/src/client/shared/opfs.ts +++ b/src/client/shared/opfs.ts @@ -3,9 +3,18 @@ import { ScramjetClient } from "../client"; export default function (client: ScramjetClient, self: Self) { client.Proxy("StorageManager.prototype.getDirectory", { apply(ctx) { - const directory = ctx.call() as FileSystemDirectoryHandle; + const directoryPromise = ctx.call() as Promise; ctx.return( - directory.getDirectoryHandle(client.url.origin, { create: true }) + (async () => { + const directory = await directoryPromise; + + return directory.getDirectoryHandle( + `${client.url.hostname.replace(/\/|\s|\./g, "-")}`, + { + create: true, + } + ); + })() ); }, });