修复文件上传时文件名读取错误的问题

This commit is contained in:
2022-07-21 12:05:18 +08:00
parent ba50ef22e3
commit aa95b36d6b
2 changed files with 4 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "yizhi-multipart-reader", "name": "yizhi-multipart-reader",
"version": "1.0.3", "version": "1.0.4",
"description": "", "description": "",
"main": "dist/index.js", "main": "dist/index.js",
"types": "typing/index.d.ts", "types": "typing/index.d.ts",

View File

@ -284,8 +284,9 @@ export class MultipartReader {
if (key == 'content-disposition') { if (key == 'content-disposition') {
const items = val.split(/;/).map(s => s.trim()).filter(s => !!s) const items = val.split(/;/).map(s => s.trim()).filter(s => !!s)
items.forEach(item => { items.forEach(item => {
let [k, v] = item.split(/=/) const matchItem = item.match(/^([\s\S]+?)=([\s\S]+?)$/)
if (!v) return if (!matchItem) return
let [k, v] = matchItem.map(s => s.trim())
k = k.toLowerCase() k = k.toLowerCase()
//去除引号 //去除引号
if (v[0] == '"' && v[v.length - 1] == '"') v = v.substring(1, v.length - 1) if (v[0] == '"' && v[v.length - 1] == '"') v = v.substring(1, v.length - 1)