File tree 2 files changed +45
-3
lines changed
2 files changed +45
-3
lines changed Original file line number Diff line number Diff line change @@ -575,11 +575,11 @@ export function createHandler<
575
575
// TODO: handle the weight parameter "q"
576
576
const [ mediaType , ...params ] = accept . split ( ';' ) ;
577
577
const charset =
578
- params ?. find ( ( param ) => param . includes ( 'charset=' ) ) || 'charset=utf8 ' ; // utf-8 is assumed when not specified;
578
+ params ?. find ( ( param ) => param . includes ( 'charset=' ) ) || 'charset=utf-8 ' ; // utf-8 is assumed when not specified;
579
579
580
580
if (
581
581
mediaType === 'application/graphql-response+json' &&
582
- charset === 'charset=utf8 '
582
+ charset === 'charset=utf-8 '
583
583
) {
584
584
acceptedMediaType = 'application/graphql-response+json' ;
585
585
break ;
@@ -590,7 +590,7 @@ export function createHandler<
590
590
( mediaType === 'application/json' ||
591
591
mediaType === 'application/*' ||
592
592
mediaType === '*/*' ) &&
593
- charset === 'charset=utf8'
593
+ ( charset === 'charset=utf-8' || charset === 'charset= utf8')
594
594
) {
595
595
acceptedMediaType = 'application/json' ;
596
596
break ;
Original file line number Diff line number Diff line change @@ -415,3 +415,45 @@ it('should use the default if nothing is returned from the custom request params
415
415
]
416
416
` ) ;
417
417
} ) ;
418
+
419
+ it ( 'should accept both utf-8 and utf8 charsets ' , async ( ) => {
420
+ const { request } = createTHandler ( ) ;
421
+
422
+ await expect (
423
+ request (
424
+ 'GET' ,
425
+ { query : '{ __typename }' } ,
426
+ { accept : 'application/json; charset=utf8' } ,
427
+ ) ,
428
+ ) . resolves . toMatchInlineSnapshot ( `
429
+ [
430
+ "{"data":{"__typename":"Query"}}",
431
+ {
432
+ "headers": {
433
+ "content-type": "application/json; charset=utf-8",
434
+ },
435
+ "status": 200,
436
+ "statusText": "OK",
437
+ },
438
+ ]
439
+ ` ) ;
440
+
441
+ await expect (
442
+ request (
443
+ 'GET' ,
444
+ { query : '{ __typename }' } ,
445
+ { accept : 'application/json; charset=utf-8' } ,
446
+ ) ,
447
+ ) . resolves . toMatchInlineSnapshot ( `
448
+ [
449
+ "{"data":{"__typename":"Query"}}",
450
+ {
451
+ "headers": {
452
+ "content-type": "application/json; charset=utf-8",
453
+ },
454
+ "status": 200,
455
+ "statusText": "OK",
456
+ },
457
+ ]
458
+ ` ) ;
459
+ } ) ;
You can’t perform that action at this time.
0 commit comments