feat: refactor whole bunch of stuff
This commit is contained in:
@@ -63,8 +63,8 @@ function parseParams(reqUrl: URL): ImageParams | string {
|
||||
async function generateETag(content: ArrayBuffer): Promise<string> {
|
||||
const hashBuffer = await crypto.subtle.digest("SHA-256", content);
|
||||
return `"${Array.from(new Uint8Array(hashBuffer))
|
||||
.map((b) => b.toString(16).padStart(2, "0"))
|
||||
.join("")
|
||||
.map((b) => b.toString(16).padStart(2, "0"))
|
||||
.join("")
|
||||
}"`;
|
||||
}
|
||||
|
||||
@@ -80,13 +80,9 @@ async function GET(req: Request, _ctx: FreshContext): Promise<Response> {
|
||||
});
|
||||
}
|
||||
|
||||
const imageUrl = params.image.startsWith("resources")
|
||||
? `https://marka.max-richter.dev/${params.image.replace(/^\//, "")}`
|
||||
: params.image;
|
||||
log.debug("Processing image request:", { params });
|
||||
|
||||
log.debug("Processing image request:", { imageUrl, params });
|
||||
|
||||
const image = await getImageContent(imageUrl, params);
|
||||
const image = await getImageContent(params.image, params);
|
||||
|
||||
// Generate ETag based on image content
|
||||
const eTag = await generateETag(image.content);
|
||||
|
||||
Reference in New Issue
Block a user