mirror of
https://github.com/p-stream/p-stream.git
synced 2026-05-02 20:04:50 +00:00
17 lines
503 B
TypeScript
17 lines
503 B
TypeScript
import { ExtensionMakeRequestBodyType } from "./plasmo";
|
|
|
|
export function getBodyTypeFromBody(
|
|
body: unknown,
|
|
): ExtensionMakeRequestBodyType {
|
|
if (typeof body === "string") return "string";
|
|
if (body instanceof FormData) return "FormData";
|
|
if (body instanceof URLSearchParams) return "URLSearchParams";
|
|
return "object";
|
|
}
|
|
|
|
export function convertBodyToObject(body: unknown): any {
|
|
if (body instanceof FormData || body instanceof URLSearchParams) {
|
|
return [...body];
|
|
}
|
|
return body;
|
|
}
|