Skip to content

Commit

Permalink
fix real url passed over protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettCleary committed Jan 15, 2025
1 parent f9efb8a commit 763b54d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/backend/images_cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ export const initImagesCache = () => {
}

const getImageFromCache = (url: string) => {
const realUrl = url.replace('imagecache://', '')
let realUrl = url.replace('imagecache://', '')
// digest of the image url for the file name
const digest = createHash('sha256').update(realUrl).digest('hex')
const cachePath = join(imagesCachePath, digest)

if (!existsSync(cachePath) && realUrl.startsWith('http')) {
realUrl = realUrl.replace('https//', 'https://')
realUrl = realUrl.replace('http//', 'http://')
// if not found, download in the background
axios
.get(realUrl, { responseType: 'stream' })
Expand Down

0 comments on commit 763b54d

Please sign in to comment.