Skip to content

Commit 837b280

Browse files
committed
fix: 修复HTTPS下无法下载的问题
1 parent a3db08c commit 837b280

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/preview.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/uploader.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,12 @@ async function uploadRemoteImage(params: {
299299
)
300300

301301
try {
302+
const url = params.src.replace(/^https?:/i, '')
302303
const { headers, data } = await axios.get(params.src, { responseType: 'arraybuffer' })
303304

304305
const contentType = (headers['content-type'] || '').toLowerCase().trim()
305306
if (!data || data.byteLength <= 0 || !contentType || !contentType.startsWith('image/')) {
306-
throw new Error('无法下载远程图片,请手动上传')
307+
throw new Error()
307308
}
308309

309310
const spark = new Spark.ArrayBuffer()
@@ -338,7 +339,7 @@ async function uploadRemoteImage(params: {
338339
width: params.width,
339340
height: params.height,
340341
},
341-
error: error.message || '未知错误',
342+
error: '无法下载远程图片,请手动上传',
342343
})
343344
}
344345

0 commit comments

Comments
 (0)