File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -247,6 +247,22 @@ describe('FormData', () => {
247247 } )
248248 } )
249249
250+ 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+ } )
265+
250266 it ( 'Should return `foo[]` as an array' , async ( ) => {
251267 const form = new FormData ( )
252268 form . append ( 'foo[]' , 'bar1' )
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ type ExcludeResponseType<T> = T extends Response & TypedResponse<any> ? never :
2525
2626const jsonRegex = / ^ a p p l i c a t i o n \/ ( [ a - z -\. ] + \+ ) ? j s o n ( ; \s * [ a - z A - Z 0 - 9 \- ] + \= ( [ ^ ; ] + ) ) * $ /
2727const multipartRegex = / ^ m u l t i p a r t \/ f o r m - d a t a ( ; \s ? b o u n d a r y = [ a - z A - Z 0 - 9 ' " ( ) + _ , \- . / : = ? ] + ) ? $ /
28- const urlencodedRegex = / ^ a p p l i c a t i o n \/ x - w w w - f o r m - u r l e n c o d e d $ /
28+ const urlencodedRegex = / ^ a p p l i c a t i o n \/ x - w w w - f o r m - u r l e n c o d e d ( ; \s * [ a - z A - Z 0 - 9 \- ] + \= ( [ ^ ; ] + ) ) * $ /
2929
3030export const validator = <
3131 InputType ,
You can’t perform that action at this time.
0 commit comments