Skip to content

Commit

Permalink
Merge branch 'Shelf-nu:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
anatolinicolae authored Mar 20, 2024
2 parents 2043ff9 + 5ae17e6 commit 48a2be6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions app/routes/api+/asset.refresh-main-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion app/utils/storage.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 48a2be6

Please sign in to comment.