This commit is contained in:
David Négrier 2020-10-01 15:55:23 +02:00
parent d3fa901691
commit e4872c6f9d
4 changed files with 56 additions and 59 deletions

View file

@ -31,7 +31,7 @@ const handleBody = (res: HttpResponse, req: HttpRequest) => {
if (contType.includes('application/json'))
res.json = async () => JSON.parse(await res.body());
if (contTypes.map(t => contType.indexOf(t) > -1).indexOf(true) > -1)
if (contTypes.map(t => contType.includes(t)).includes(true))
res.formData = formData.bind(res, contType);
};

View file

@ -15,7 +15,7 @@ function formData(
encoding: string,
mimetype: string
) => string;
onField?: (fieldname: string, value: any) => void;
onField?: (fieldname: string, value: any) => void; // eslint-disable-line @typescript-eslint/no-explicit-any
filename?: (oldName: string) => string;
} = {}
) {
@ -75,11 +75,11 @@ function formData(
}
function setRetValue(
ret: { [x: string]: any },
ret: { [x: string]: any }, // eslint-disable-line @typescript-eslint/no-explicit-any
fieldname: string,
value: { filename: string; encoding: string; mimetype: string; filePath?: string } | any
value: { filename: string; encoding: string; mimetype: string; filePath?: string } | any // eslint-disable-line @typescript-eslint/no-explicit-any
) {
if (fieldname.slice(-2) === '[]') {
if (fieldname.endsWith('[]')) {
fieldname = fieldname.slice(0, fieldname.length - 2);
if (Array.isArray(ret[fieldname])) {
ret[fieldname].push(value);