Skip to content

Commit

Permalink
[fix] File Name parameter of Form Data utility
Browse files Browse the repository at this point in the history
[optimize] update Upstream packages
  • Loading branch information
TechQuery committed Nov 24, 2023
1 parent 5cafcf2 commit 7c81d39
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 48 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "koajax",
"version": "0.9.5",
"version": "0.9.6",
"license": "LGPL-3.0",
"author": "[email protected]",
"description": "HTTP Client based on Koa-like middlewares",
Expand Down Expand Up @@ -37,9 +37,9 @@
"@parcel/packager-ts": "~2.10.3",
"@parcel/transformer-typescript-types": "~2.10.3",
"@types/core-js": "^2.5.8",
"@types/jest": "^29.5.9",
"@types/jest": "^29.5.10",
"@types/jsdom": "^21.1.6",
"@types/node": "^18.18.11",
"@types/node": "^18.18.13",
"core-js": "^3.33.3",
"cross-env": "^7.0.3",
"husky": "^8.0.3",
Expand Down
80 changes: 40 additions & 40 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions source/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ export function makeFormData(data: Record<string, any>) {
typeof value !== 'string' && likeArray(value) ? value : [value]
) as ArrayLike<string | Blob>;

Array.from(list, item => item != null && formData.append(key, item));
for (const item of Array.from(list))
if (item != null)
if (typeof item === 'object')
formData.append(key, item, (item as File).name);
else formData.append(key, item);
}

return formData;
}

Expand All @@ -33,9 +36,9 @@ export function serializeNode(root: Node) {
root instanceof SVGElement
? 'image/svg'
: root instanceof HTMLDocument ||
root instanceof HTMLElement
? 'text/html'
: 'application/xml',
root instanceof HTMLElement
? 'text/html'
: 'application/xml',
data: stringifyDOM(root)
};

Expand Down

0 comments on commit 7c81d39

Please sign in to comment.