You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
503 B
17 lines
503 B
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; |
|
}
|
|
|