Skip to content

Commit

Permalink
test: add test to ensure full type when parsing multipart/form-data' (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak authored Oct 5, 2024
1 parent 773ba01 commit f96f37c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/issue-2283.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict'

const { tspl } = require('@matteo.collina/tspl')
const { describe, test } = require('node:test')
const { FormData, Response } = require('..')

describe('https://github.com/nodejs/undici/issues/2283', () => {
test('preserve full type when parsing multipart/form-data', async (t) => {
t = tspl(t, { plan: 2 })
const testBlob = new Blob(['123'], { type: 'text/plain;charset=utf-8' })
const fd = new FormData()
fd.set('x', testBlob)
const res = new Response(fd)
res.clone().text().then(body =>
// Just making sure that it contains ;charset=utf-8
t.ok(body.includes('text/plain;charset=utf-8'))
)

new Response(fd).formData().then(fd => {
// returns just 'text/plain'
t.ok(fd.get('x').type === 'text/plain;charset=utf-8')
})

await t.completed
})
})

0 comments on commit f96f37c

Please sign in to comment.