microsoft/vscode-react-native

Public

mirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1.7.1

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/extension/networkInspector/requestBodyFormatters/imageFormatter.ts

31lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
4import { IFormatter, FormattedBody } from "./requestBodyFormatter";
5import { Response } from "../networkMessageData";
6
7/**
8 * @preserve
9 * Start region: the code is borrowed from https://github.com/facebook/flipper/blob/v0.79.1/desktop/plugins/network/RequestDetails.tsx#L482-L497
10 *
11 * Copyright (c) Facebook, Inc. and its affiliates.
12 *
13 * This source code is licensed under the MIT license found in the
14 * LICENSE file in the root directory of this source tree.
15 *
16 * @format
17 */
18
19export class ImageFormatter implements IFormatter {
20 public formatResponse(response: Response, contentType: string): FormattedBody | null {
21 if (contentType.startsWith("image/") && response.data) {
22 return response.data;
23 }
24 return null;
25 }
26}
27
28/**
29 * @preserve
30 * End region: https://github.com/facebook/flipper/blob/v0.79.1/desktop/plugins/network/RequestDetails.tsx#L482-L497
31 */
32