Skip to content
Myr

fix(validator): Fixed a bug in hono/validator where URL Encoded Data could not be validated if the Content-Type included charset. (#3297)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by uttk · committed by GitHub · parent 17c3b9e · Browse files · 2 files+17 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+17 added−1 removed

  • tests:+16 added−0 removed
  • other:+1 added−1 removed

2 files+17 added−1 removed

modified:src/validator/validator.test.ts+16 added
245 unmodified lines
246 foo: 'bar',247 })248 })249250 it('Should validate if Content-Type is a application/x-www-form-urlencoded with a charset', async () => {251 const params = new URLSearchParams()252 params.append('foo', 'bar')253 const res = await app.request('/post', {254 method: 'POST',255 body: params,256 headers: {257 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',258 },259 })260 expect(res.status).toBe(200)261 expect(await res.json()).toEqual({262 foo: 'bar',263 })264 })265266 it('Should return `foo[]` as an array', async () => {267 const form = new FormData()268 form.append('foo[]', 'bar1')269 form.append('foo[]', 'bar2')
940 unmodified lines
modified:src/validator/validator.ts+1 added-1 removed