Open History to see the last commit
1/** String form of a primitive. Objects become '' instead of `[object Object]`. */
2export function asText(value: unknown): string {
3 if (
4 typeof value === 'string' ||
5 typeof value === 'number' ||
6 typeof value === 'boolean' ||
7 typeof value === 'bigint'
8 ) {
9 return String(value)
10 }
11 return ''
12}
13
14export function requestUrl(input: RequestInfo | URL): string {
15 if (typeof input === 'string') return input
16 if (input instanceof URL) return input.href
17 return input.url
18}
19
20export function bodyText(body: BodyInit | null | undefined): string {
21 if (typeof body === 'string') return body
22 if (body instanceof URLSearchParams) return body.toString()
23 return ''
24}