Skip to content

Commit

Permalink
fix: cache key generation
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKruckenberg committed Mar 30, 2021
1 parent 1a50520 commit e09434c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/core/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ import sharp from "sharp";
import { ImageConfig } from "./types";
import { createHash } from 'crypto'

export function loadImageFromDisk(path: string) {
export function loadImage(path: string) {
return sharp(path)
}

export function loadImageFromBuffer(buf: Buffer) {
return sharp(buf)
}

export function generateImageID(url:URL, config:ImageConfig) {
const baseURL = new URL(url.origin + url.pathname)
const baseURL = url.host
? new URL(url.origin + url.pathname)
: new URL(url.protocol + url.pathname)

return createHash('sha1').update(baseURL.href).update(JSON.stringify(config)).digest('hex')
}

0 comments on commit e09434c

Please sign in to comment.