fix: fetch error due to header get failed (#239)

Co-authored-by: 42 <37006258+MirrorCY@users.noreply.github.com>
This commit is contained in:
Maiko Sinkyaet Tan 2024-03-02 21:48:58 +08:00 committed by GitHub
parent 685e50f450
commit 6d8d634624
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -63,7 +63,7 @@
"generate"
],
"peerDependencies": {
"koishi": "^4.16.8"
"koishi": "^4.17.0-alpha.0"
},
"devDependencies": {
"@cordisjs/vitepress": "^3.2.6",
@ -73,7 +73,7 @@
"@types/libsodium-wrappers-sumo": "^0.7.8",
"@types/node": "^20.11.19",
"atsc": "^1.2.2",
"koishi": "^4.16.8",
"koishi": "^4.17.0",
"sass": "^1.71.0",
"typescript": "^5.3.3",
"vitepress": "1.0.0-rc.40"

View File

@ -441,13 +441,13 @@ export function apply(ctx: Context, config: Config) {
}
const imgRes = await ctx.http.axios(imgUrl, { responseType: 'arraybuffer' })
const b64 = Buffer.from(imgRes.data).toString('base64')
return forceDataPrefix(b64, imgRes.headers['content-type'])
return forceDataPrefix(b64, imgRes.headers.get('content-type'))
}
// event: newImage
// id: 1
// data:
if (res.headers['content-type'] === 'application/x-zip-compressed') {
if (res.headers.get('content-type') === 'application/x-zip-compressed') {
const buffer = Buffer.from(res.data, 'binary') // Ensure 'binary' encoding
const zip = new AdmZip(buffer)