Convert Flipper plugin "Network" to TypeScript
Summary: _typescript_ Reviewed By: jknoxville Differential Revision: D17155508 fbshipit-source-id: 2452b023dd3a5f0063e4b6b6294ed00670ec9022
This commit is contained in:
committed by
Facebook Github Bot
parent
4781f04ca4
commit
0a53cccb40
@@ -24,7 +24,7 @@ import {
|
||||
styled,
|
||||
colors,
|
||||
} from 'flipper';
|
||||
import {decodeBody, getHeaderValue} from './utils.js';
|
||||
import {decodeBody, getHeaderValue} from './utils.tsx';
|
||||
import {formatBytes} from './index.js';
|
||||
|
||||
import querystring from 'querystring';
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {convertRequestToCurlCommand} from '../utils.js';
|
||||
import type {Request} from '../types.tsx';
|
||||
import {convertRequestToCurlCommand} from '../utils';
|
||||
import {Request} from '../types';
|
||||
|
||||
test('convertRequestToCurlCommand: simple GET', () => {
|
||||
const request: Request = {
|
||||
@@ -31,7 +31,7 @@ import {
|
||||
convertRequestToCurlCommand,
|
||||
getHeaderValue,
|
||||
decodeBody,
|
||||
} from './utils.js';
|
||||
} from './utils.tsx';
|
||||
import RequestDetails from './RequestDetails.js';
|
||||
import {clipboard} from 'electron';
|
||||
import {URL} from 'url';
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"pako": "^1.0.6",
|
||||
"@types/pako": "^1.0.1",
|
||||
"xml-beautifier": "^0.4.0",
|
||||
"lodash": "^4.17.11"
|
||||
},
|
||||
|
||||
@@ -5,9 +5,8 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
// $FlowFixMe
|
||||
import pako from 'pako';
|
||||
import type {Request, Response, Header} from './types.tsx';
|
||||
import {Request, Response, Header} from './types';
|
||||
|
||||
export function getHeaderValue(headers: Array<Header>, key: string): string {
|
||||
for (const header of headers) {
|
||||
@@ -62,7 +61,7 @@ export function convertRequestToCurlCommand(request: Request): string {
|
||||
let command: string = `curl -v -X ${request.method}`;
|
||||
command += ` ${escapedString(request.url)}`;
|
||||
// Add headers
|
||||
request.headers.forEach(header => {
|
||||
request.headers.forEach((header: Header) => {
|
||||
const headerStr = `${header.key}: ${header.value}`;
|
||||
command += ` -H ${escapedString(headerStr)}`;
|
||||
});
|
||||
@@ -74,7 +73,7 @@ export function convertRequestToCurlCommand(request: Request): string {
|
||||
return command;
|
||||
}
|
||||
|
||||
function escapeCharacter(x) {
|
||||
function escapeCharacter(x: string) {
|
||||
const code = x.charCodeAt(0);
|
||||
return code < 16 ? '\\u0' + code.toString(16) : '\\u' + code.toString(16);
|
||||
}
|
||||
@@ -83,7 +82,7 @@ const needsEscapingRegex = /[\u0000-\u001f\u007f-\u009f!]/g;
|
||||
|
||||
// Escape util function, inspired by Google DevTools. Works only for POSIX
|
||||
// based systems.
|
||||
function escapedString(str) {
|
||||
function escapedString(str: string) {
|
||||
if (needsEscapingRegex.test(str) || str.includes("'")) {
|
||||
return (
|
||||
"$'" +
|
||||
@@ -2,14 +2,20 @@
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@types/pako@^1.0.1":
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/pako/-/pako-1.0.1.tgz#33b237f3c9aff44d0f82fe63acffa4a365ef4a61"
|
||||
integrity sha512-GdZbRSJ3Cv5fiwT6I0SQ3ckeN2PWNqxd26W9Z2fCK1tGrrasGy4puvNFtnddqH9UJFMQYXxEuuB7B8UK+LLwSg==
|
||||
|
||||
lodash@^4.17.11:
|
||||
version "4.17.11"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
|
||||
integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==
|
||||
version "4.17.15"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
|
||||
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
|
||||
|
||||
pako@^1.0.6:
|
||||
version "1.0.6"
|
||||
resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.6.tgz#0101211baa70c4bca4a0f63f2206e97b7dfaf258"
|
||||
version "1.0.10"
|
||||
resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.10.tgz#4328badb5086a426aa90f541977d4955da5c9732"
|
||||
integrity sha512-0DTvPVU3ed8+HNXOu5Bs+o//Mbdj9VNQMUOe9oKCwh8l0GNwpTDMKCWbRjgtD291AWnkAgkqA/LOnQS8AmS1tw==
|
||||
|
||||
repeat-string@1.6.1:
|
||||
version "1.6.1"
|
||||
@@ -17,8 +23,8 @@ repeat-string@1.6.1:
|
||||
integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc=
|
||||
|
||||
xml-beautifier@^0.4.0:
|
||||
version "0.4.0"
|
||||
resolved "https://registry.yarnpkg.com/xml-beautifier/-/xml-beautifier-0.4.0.tgz#8ead9e48aa4ffc9c702eca82d53130f0f3aa3c48"
|
||||
integrity sha512-aIoZ2Dx0VkYuvP35WAdMDi7voG1Kn36vi7jKkHuLx5K5fqJeynNqKulSvyFpNu2+VNtDfbggd+GbDdGIF/ZJSw==
|
||||
version "0.4.2"
|
||||
resolved "https://registry.yarnpkg.com/xml-beautifier/-/xml-beautifier-0.4.2.tgz#d889df69b46a6ed1ab46fbe022930da83bf40f7c"
|
||||
integrity sha512-LBZ3bLvo3FZIN9nBjxUpi70L1nGDOzTaLQm8eNyi0nyr8uUV2YLg0C2DSihc3OahcgWQoQ83ZTm0RErKuRrJYQ==
|
||||
dependencies:
|
||||
repeat-string "1.6.1"
|
||||
|
||||
Reference in New Issue
Block a user