From b3847b093e7ab8d11dac626affb54573a1903ace Mon Sep 17 00:00:00 2001 From: Jacob Ebey Date: Tue, 4 Jan 2022 20:29:24 -0800 Subject: [PATCH] updated hash to take into account params --- images/route.server.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/images/route.server.ts b/images/route.server.ts index 00db0c6..3d91e3b 100644 --- a/images/route.server.ts +++ b/images/route.server.ts @@ -40,10 +40,17 @@ export let loader: LoaderFunction = async ({ request }) => { return badImageResponse(); } + let width = getIntOrNull(url.searchParams.get("width")); + let height = getIntOrNull(url.searchParams.get("height")); + let fit: any = url.searchParams.get("fit") || "cover"; + let hash = createHash("sha256"); hash.update("v1"); hash.update(request.method); hash.update(request.url); + hash.update(width?.toString() || "0"); + hash.update(height?.toString() || "0"); + hash.update(fit); let key = hash.digest("hex"); let cachedFile = path.resolve(path.join(".cache/images", key + ".webp")); @@ -95,9 +102,6 @@ export let loader: LoaderFunction = async ({ request }) => { console.error(error); }); - let width = getIntOrNull(url.searchParams.get("width")); - let height = getIntOrNull(url.searchParams.get("height")); - let fit: any = url.searchParams.get("fit") || "cover"; if (width || height) { sharpInstance.resize(width, height, { fit }); }