Make sure network plugin doesn't crash on invalid URLs
Summary: In the attached task an IPv6 address ended up in the URL send from IG. Since that URL couldn't be parsed, it crashed the network plugin. This change makes sure the plugin doesn't crash on invalid urls. Reviewed By: cekkaewnumchai Differential Revision: D23344503 fbshipit-source-id: c7ac2068e407a764d59e632bef1be7c4239c8c8a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2f7a84115c
commit
cd197aeaaf
@@ -29,6 +29,7 @@ export {
|
|||||||
MenuEntry,
|
MenuEntry,
|
||||||
NormalizedMenuEntry,
|
NormalizedMenuEntry,
|
||||||
buildInMenuEntries,
|
buildInMenuEntries,
|
||||||
|
DefaultKeyboardAction,
|
||||||
} from './plugin/MenuEntry';
|
} from './plugin/MenuEntry';
|
||||||
|
|
||||||
// It's not ideal that this exists in flipper-plugin sources directly,
|
// It's not ideal that this exists in flipper-plugin sources directly,
|
||||||
|
|||||||
@@ -7,10 +7,10 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export type DefaultKeyboardAction = 'clear' | 'goToBottom' | 'createPaste';
|
|
||||||
export type TopLevelMenu = 'Edit' | 'View' | 'Window' | 'Help';
|
export type TopLevelMenu = 'Edit' | 'View' | 'Window' | 'Help';
|
||||||
|
|
||||||
export type MenuEntry = BuiltInMenuEntry | CustomMenuEntry;
|
export type MenuEntry = BuiltInMenuEntry | CustomMenuEntry;
|
||||||
|
export type DefaultKeyboardAction = keyof typeof buildInMenuEntries;
|
||||||
|
|
||||||
export type NormalizedMenuEntry = {
|
export type NormalizedMenuEntry = {
|
||||||
label: string;
|
label: string;
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ import {convertRequestToCurlCommand, getHeaderValue, decodeBody} from './utils';
|
|||||||
import RequestDetails from './RequestDetails';
|
import RequestDetails from './RequestDetails';
|
||||||
import {clipboard} from 'electron';
|
import {clipboard} from 'electron';
|
||||||
import {URL} from 'url';
|
import {URL} from 'url';
|
||||||
import {DefaultKeyboardAction} from 'app/src/MenuBar';
|
|
||||||
import {MockResponseDialog} from './MockResponseDialog';
|
import {MockResponseDialog} from './MockResponseDialog';
|
||||||
import {combineBase64Chunks} from './chunks';
|
import {combineBase64Chunks} from './chunks';
|
||||||
|
import {DefaultKeyboardAction} from 'flipper-plugin';
|
||||||
|
|
||||||
const LOCALSTORAGE_MOCK_ROUTE_LIST_KEY = '__NETWORK_CACHED_MOCK_ROUTE_LIST';
|
const LOCALSTORAGE_MOCK_ROUTE_LIST_KEY = '__NETWORK_CACHED_MOCK_ROUTE_LIST';
|
||||||
|
|
||||||
@@ -599,8 +599,13 @@ function buildRow(
|
|||||||
if (request.url == null) {
|
if (request.url == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const url = new URL(request.url);
|
let url: URL | undefined = undefined;
|
||||||
const domain = url.host + url.pathname;
|
try {
|
||||||
|
url = new URL(request.url);
|
||||||
|
} catch (e) {
|
||||||
|
console.warn(`Failed to parse url: '${request.url}'`, e);
|
||||||
|
}
|
||||||
|
const domain = url ? url.host + url.pathname : '<unknown>';
|
||||||
const friendlyName = getHeaderValue(request.headers, 'X-FB-Friendly-Name');
|
const friendlyName = getHeaderValue(request.headers, 'X-FB-Friendly-Name');
|
||||||
const style = response && response.isMock ? mockingStyle : undefined;
|
const style = response && response.isMock ? mockingStyle : undefined;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user