Detect JSON API content type ('application/vnd.api+json') as textual content (#2337)
Summary: Network requests and responses using JSON API content type of pattern `application/vnd.api+json` (see https://jsonapi.org/#mime-types) are currently treated as binary data. They should be treated as textual content. ## Changelog Add regular expression to detect JSON content types. Pull Request resolved: https://github.com/facebook/flipper/pull/2337 Test Plan: Using an API that return `Content-Type` of pattern `application/vnd.api+json`, verify that the response data in sidebar appears as text rather than `(binary data)`. Reviewed By: passy Differential Revision: D28513547 Pulled By: mweststrate fbshipit-source-id: 3335b7eeb63c2429c2245113c8c83bd7e08a9420
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4cdc72aba4
commit
525e8b19fb
@@ -26,6 +26,9 @@ export function getHeaderValue(
|
||||
return '';
|
||||
}
|
||||
|
||||
// Matches `application/json` and `application/vnd.api.v42+json` (see https://jsonapi.org/#mime-types)
|
||||
const jsonContentTypeRegex = new RegExp('application/(json|.+\\+json)');
|
||||
|
||||
export function isTextual(headers?: Array<Header>): boolean {
|
||||
const contentType = getHeaderValue(headers, 'Content-Type');
|
||||
if (!contentType) {
|
||||
@@ -36,7 +39,7 @@ export function isTextual(headers?: Array<Header>): boolean {
|
||||
return (
|
||||
contentType.startsWith('text/') ||
|
||||
contentType.startsWith('application/x-www-form-urlencoded') ||
|
||||
contentType.startsWith('application/json') ||
|
||||
jsonContentTypeRegex.test(contentType) ||
|
||||
contentType.startsWith('multipart/') ||
|
||||
contentType.startsWith('message/') ||
|
||||
contentType.startsWith('image/svg') ||
|
||||
|
||||
Reference in New Issue
Block a user