File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -1211,8 +1211,15 @@ export default class ApiRequest extends LitElement {
1211
1211
const contentType = tryResp . headers . get ( 'content-type' ) ;
1212
1212
if ( contentType ) {
1213
1213
if ( contentType . includes ( 'json' ) ) {
1214
- respJson = await tryResp . json ( ) ;
1215
- me . responseText = JSON . stringify ( respJson , null , 2 ) ;
1214
+ if ( / c h a r s e t = [ ^ " ' ] + / ) . test ( contentType ) ) {
1215
+ const enc = contentType . split ( 'charset=' ) [ 1 ] ;
1216
+ const buffer = await tryResp . arrayBuffer ( ) ;
1217
+ const respJson = new TextDecoder ( enc ) . decode ( buffer ) ;
1218
+ me . responseText = JSON . stringify ( respJson , null , 2 ) ;
1219
+ } else {
1220
+ respJson = await tryResp . json ( ) ;
1221
+ me . responseText = JSON . stringify ( respJson , null , 2 ) ;
1222
+ }
1216
1223
} else if ( RegExp ( '^font/|tar$|zip$|7z$|rtf$|msword$|excel$|/pdf$|/octet-stream$' ) . test ( contentType ) ) {
1217
1224
me . responseIsBlob = true ;
1218
1225
me . responseBlobType = 'download' ;
You can’t perform that action at this time.
0 commit comments