diff --git a/lib/fetch/body.js b/lib/fetch/body.js index 11b945d18bf..105eb553157 100644 --- a/lib/fetch/body.js +++ b/lib/fetch/body.js @@ -387,6 +387,7 @@ function bodyMixinMethods (instance) { try { busboy = Busboy({ headers, + preservePath: true, defParamCharset: 'utf8' }) } catch (err) { diff --git a/test/fetch/client-fetch.js b/test/fetch/client-fetch.js index 048b76a9f78..9009d547ec6 100644 --- a/test/fetch/client-fetch.js +++ b/test/fetch/client-fetch.js @@ -272,6 +272,18 @@ test('busboy emit error', async (t) => { await t.rejects(res.formData(), 'Unexpected end of multipart data') }) +// https://github.com/nodejs/undici/issues/2244 +test('parsing formData preserve full path on files', async (t) => { + t.plan(1) + const formData = new FormData() + formData.append('field1', new File(['foo'], 'a/b/c/foo.txt')) + + const tempRes = new Response(formData) + const form = await tempRes.formData() + + t.equal(form.get('field1').name, 'a/b/c/foo.txt') +}) + test('urlencoded formData', (t) => { t.plan(2)