Skip to content

Commit

Permalink
fix: remove quotes from etag (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
ascorbic authored Jan 5, 2023
1 parent 1a2009b commit e4101c0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
],
"ignorePatterns": "dist",
"rules": {
"import/named": "off"
"import/named": "off",
"vue/valid-attribute-name": "off"
}
}
3 changes: 2 additions & 1 deletion src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ export async function loadSourceImage ({ cacheDir, url, requestEtag, modifiers,
// either an etag or a last-modified date for the source image to do so.
let responseEtag
if (metadata.etag || metadata.lastModified) {
responseEtag = etag(`${cacheKey}${metadata.etag || metadata.lastModified}${modifiers}`)
// etag returns a quoted string for some reason
responseEtag = JSON.parse(etag(`${cacheKey}${metadata.etag || metadata.lastModified}${modifiers}`))
if (requestEtag && (requestEtag === responseEtag)) {
return {
response: {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export function createIPXHandler ({
const body =
typeof res.body === 'string' ? res.body : res.body.toString('base64')

res.headers.etag = responseEtag || etag(body)
res.headers.etag = responseEtag || JSON.parse(etag(body))
delete res.headers['Last-Modified']

if (requestEtag && requestEtag === res.headers.etag) {
Expand Down

0 comments on commit e4101c0

Please sign in to comment.