Decapitate "network" plugin
Reviewed By: lawrencelomax Differential Revision: D39466980 fbshipit-source-id: b880690a2b334fd063f2d06923743d67b79e7b08
This commit is contained in:
committed by
Facebook GitHub Bot
parent
cb610ec751
commit
f463520522
@@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {Component} from 'react';
|
import {Component} from 'react';
|
||||||
import querystring from 'querystring';
|
|
||||||
import xmlBeautifier from 'xml-beautifier';
|
import xmlBeautifier from 'xml-beautifier';
|
||||||
import {Base64} from 'js-base64';
|
import {Base64} from 'js-base64';
|
||||||
|
|
||||||
@@ -23,7 +22,13 @@ import {
|
|||||||
} from 'flipper-plugin';
|
} from 'flipper-plugin';
|
||||||
import {Select, Typography} from 'antd';
|
import {Select, Typography} from 'antd';
|
||||||
|
|
||||||
import {bodyAsBinary, bodyAsString, formatBytes, getHeaderValue} from './utils';
|
import {
|
||||||
|
bodyAsBinary,
|
||||||
|
bodyAsString,
|
||||||
|
formatBytes,
|
||||||
|
getHeaderValue,
|
||||||
|
queryToObj,
|
||||||
|
} from './utils';
|
||||||
import {Request, Header, Insights, RetryInsights} from './types';
|
import {Request, Header, Insights, RetryInsights} from './types';
|
||||||
import {BodyOptions} from './index';
|
import {BodyOptions} from './index';
|
||||||
import {ProtobufDefinitionsRepository} from './ProtobufDefinitionsRepository';
|
import {ProtobufDefinitionsRepository} from './ProtobufDefinitionsRepository';
|
||||||
@@ -523,7 +528,7 @@ class JSONFormatter {
|
|||||||
class LogEventFormatter {
|
class LogEventFormatter {
|
||||||
formatRequest(request: Request) {
|
formatRequest(request: Request) {
|
||||||
if (request.url.indexOf('logging_client_event') > 0) {
|
if (request.url.indexOf('logging_client_event') > 0) {
|
||||||
const data = querystring.parse(bodyAsString(request.requestData));
|
const data = queryToObj(bodyAsString(request.requestData));
|
||||||
if (typeof data.message === 'string') {
|
if (typeof data.message === 'string') {
|
||||||
data.message = JSON.parse(data.message);
|
data.message = JSON.parse(data.message);
|
||||||
}
|
}
|
||||||
@@ -535,7 +540,7 @@ class LogEventFormatter {
|
|||||||
class GraphQLBatchFormatter {
|
class GraphQLBatchFormatter {
|
||||||
formatRequest(request: Request) {
|
formatRequest(request: Request) {
|
||||||
if (request.url.indexOf('graphqlbatch') > 0) {
|
if (request.url.indexOf('graphqlbatch') > 0) {
|
||||||
const data = querystring.parse(bodyAsString(request.requestData));
|
const data = queryToObj(bodyAsString(request.requestData));
|
||||||
if (typeof data.queries === 'string') {
|
if (typeof data.queries === 'string') {
|
||||||
data.queries = JSON.parse(data.queries);
|
data.queries = JSON.parse(data.queries);
|
||||||
}
|
}
|
||||||
@@ -575,7 +580,7 @@ class GraphQLFormatter {
|
|||||||
if (!decoded) {
|
if (!decoded) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
const data = querystring.parse(bodyAsString(decoded));
|
const data = queryToObj(bodyAsString(decoded));
|
||||||
if (typeof data.variables === 'string') {
|
if (typeof data.variables === 'string') {
|
||||||
data.variables = JSON.parse(data.variables);
|
data.variables = JSON.parse(data.variables);
|
||||||
}
|
}
|
||||||
@@ -636,10 +641,7 @@ class FormUrlencodedFormatter {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<DataInspector
|
<DataInspector expandRoot data={queryToObj(bodyAsString(decoded))} />
|
||||||
expandRoot
|
|
||||||
data={querystring.parse(bodyAsString(decoded))}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ import {
|
|||||||
decodeBody,
|
decodeBody,
|
||||||
} from './utils';
|
} from './utils';
|
||||||
import RequestDetails from './RequestDetails';
|
import RequestDetails from './RequestDetails';
|
||||||
import {URL} from 'url';
|
|
||||||
import {assembleChunksIfResponseIsComplete} from './chunks';
|
import {assembleChunksIfResponseIsComplete} from './chunks';
|
||||||
import {DeleteOutlined} from '@ant-design/icons';
|
import {DeleteOutlined} from '@ant-design/icons';
|
||||||
import {ManageMockResponsePanel} from './request-mocking/ManageMockResponsePanel';
|
import {ManageMockResponsePanel} from './request-mocking/ManageMockResponsePanel';
|
||||||
|
|||||||
@@ -170,6 +170,15 @@ export function bodyAsBinary(
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const queryToObj = (query: string) => {
|
||||||
|
const params = new URLSearchParams(query);
|
||||||
|
const obj: Record<string, any> = {};
|
||||||
|
params.forEach((value, key) => {
|
||||||
|
obj[key] = value;
|
||||||
|
});
|
||||||
|
return obj;
|
||||||
|
};
|
||||||
|
|
||||||
function escapeCharacter(x: string) {
|
function escapeCharacter(x: string) {
|
||||||
const code = x.charCodeAt(0);
|
const code = x.charCodeAt(0);
|
||||||
return code < 16 ? '\\u0' + code.toString(16) : '\\u' + code.toString(16);
|
return code < 16 ? '\\u0' + code.toString(16) : '\\u' + code.toString(16);
|
||||||
|
|||||||
Reference in New Issue
Block a user