File tree Expand file tree Collapse file tree 4 files changed +5
-10
lines changed Expand file tree Collapse file tree 4 files changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -3,8 +3,7 @@ export const getResponseBody = async (response: Response): Promise<any> => {
3
3
try {
4
4
const contentType = response.headers.get('Content-Type');
5
5
if (contentType) {
6
- const jsonTypes = ['application/json', 'application/problem+json']
7
- const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type));
6
+ const isJSON = /application\\/([a-zA-Z0-9.]*\\+)?json/.test(contentType.toLowerCase());
8
7
if (isJSON) {
9
8
return await response.json();
10
9
} else {
Original file line number Diff line number Diff line change @@ -3,8 +3,7 @@ export const getResponseBody = async (response: Response): Promise<any> => {
3
3
try {
4
4
const contentType = response.headers.get('Content-Type');
5
5
if (contentType) {
6
- const jsonTypes = ['application/json', 'application/problem+json']
7
- const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type));
6
+ const isJSON = /application\\/([a-zA-Z0-9.]*\\+)?json/.test(contentType.toLowerCase());
8
7
if (isJSON) {
9
8
return await response.json();
10
9
} else {
Original file line number Diff line number Diff line change @@ -3,8 +3,7 @@ export const getResponseBody = (xhr: XMLHttpRequest): any => {
3
3
try {
4
4
const contentType = xhr.getResponseHeader('Content-Type');
5
5
if (contentType) {
6
- const jsonTypes = ['application/json', 'application/problem+json']
7
- const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type));
6
+ const isJSON = /application\\/([a-zA-Z0-9.]*\\+)?json/.test(contentType.toLowerCase());
8
7
if (isJSON) {
9
8
return JSON.parse(xhr.responseText);
10
9
} else {
Original file line number Diff line number Diff line change @@ -473,8 +473,7 @@ export const getResponseBody = async (response: Response): Promise<any> => {
473
473
try {
474
474
const contentType = response.headers.get('Content-Type');
475
475
if (contentType) {
476
- const jsonTypes = ['application/json', 'application/problem+json']
477
- const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type));
476
+ const isJSON = /application\\/([a-zA-Z0-9.]*\\+)?json/.test(contentType.toLowerCase());
478
477
if (isJSON) {
479
478
return await response.json();
480
479
} else {
@@ -3568,8 +3567,7 @@ export const getResponseBody = async (response: Response): Promise<any> => {
3568
3567
try {
3569
3568
const contentType = response.headers.get('Content-Type');
3570
3569
if (contentType) {
3571
- const jsonTypes = ['application/json', 'application/problem+json']
3572
- const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type));
3570
+ const isJSON = /application\\/([a-zA-Z0-9.]*\\+)?json/.test(contentType.toLowerCase());
3573
3571
if (isJSON) {
3574
3572
return await response.json();
3575
3573
} else {
You can’t perform that action at this time.
0 commit comments