Skip to content

Commit

Permalink
fix: handle empty content-type header (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
ascorbic authored Mar 10, 2022
1 parent 6346407 commit 2650b33
Show file tree
Hide file tree
Showing 3 changed files with 255 additions and 202 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@
"dev": "cd example && netlify dev"
},
"dependencies": {
"@netlify/functions": "^0.7.2",
"@netlify/functions": "^1.0.0",
"etag": "^1.8.1",
"fs-extra": "^10.0.0",
"ipx": "^0.9.4",
"mkdirp": "^1.0.4",
"murmurhash": "^2.0.0",
"node-fetch": "^2.0.0",
"ufo": "^0.7.10",
"ufo": "^0.7.11",
"unstorage": "^0.2.8"
},
"devDependencies": {
"@netlify/ipx": "link:.",
"@nuxtjs/eslint-config-typescript": "^6.0.1",
"@types/etag": "^1.8.1",
"@types/fs-extra": "^9.0.12",
"@types/node-fetch": "^2.0.0",
"@types/fs-extra": "^9.0.13",
"@types/node-fetch": "^2.6.1",
"eslint": "^7.29.0",
"jiti": "^1.10.1",
"jiti": "^1.13.0",
"standard-version": "^9.3.0",
"typescript": "^4.4.3"
"typescript": "^4.6.2"
}
}
9 changes: 6 additions & 3 deletions src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,15 @@ export async function loadSourceImage ({ cacheDir, url, requestEtag, modifiers,
return {
response: {
statusCode: isLocal ? response.status : GATEWAY_ERROR,
body: `Source image server responsed with ${response.status} ${response.statusText}`
body: `Source image server responsed with ${response.status} ${response.statusText}`,
headers: {
'Content-Type': 'text/plain'
}
}
}
}

if (!response.headers.get('content-type').startsWith('image/')) {
const contentType = response.headers.get('content-type')
if (contentType && !contentType.startsWith('image/')) {
return {
response: {
statusCode: GATEWAY_ERROR,
Expand Down
Loading

0 comments on commit 2650b33

Please sign in to comment.