diff --git a/app/routes/api+/asset.refresh-main-image.ts b/app/routes/api+/asset.refresh-main-image.ts index 5ac4eeb6a..652c411dd 100644 --- a/app/routes/api+/asset.refresh-main-image.ts +++ b/app/routes/api+/asset.refresh-main-image.ts @@ -24,12 +24,11 @@ export async function action({ context, request }: ActionFunctionArgs) { }) ); - const regex = - // eslint-disable-next-line no-useless-escape - /\/assets\/([a-f0-9-]+)\/([a-z0-9]+)\/([a-z0-9\-]+\.[a-z]{3,4})/i; - const match = mainImage.match(regex); - - const filename = match ? `/${match[1]}/${match[2]}/${match[3]}` : null; + const url = new URL(mainImage); + const path = url.pathname; + const start = path.indexOf("/assets/"); + const filename = + start !== -1 ? path.slice(start + "/assets/".length) : null; if (!filename) { throw new ShelfError({ diff --git a/app/utils/storage.server.ts b/app/utils/storage.server.ts index b89def53d..9ae4b54a4 100644 --- a/app/utils/storage.server.ts +++ b/app/utils/storage.server.ts @@ -51,7 +51,7 @@ export async function createSignedUrl({ const { data, error } = await getSupabaseAdmin() .storage.from(bucketName) - .createSignedUrl(filename, 86_400_000); //24h + .createSignedUrl(filename, 24 * 60 * 60); //24h if (error) { throw error;