File tree 2 files changed +17
-1
lines changed
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -247,6 +247,22 @@ describe('FormData', () => {
247
247
} )
248
248
} )
249
249
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
+
250
266
it ( 'Should return `foo[]` as an array' , async ( ) => {
251
267
const form = new FormData ( )
252
268
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 :
25
25
26
26
const 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 \- ] + \= ( [ ^ ; ] + ) ) * $ /
27
27
const 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 \- ] + \= ( [ ^ ; ] + ) ) * $ /
29
29
30
30
export const validator = <
31
31
InputType ,
You can’t perform that action at this time.
0 commit comments