Files
yaak/src-web/hooks/useContentTypeFromHeaders.ts
2024-09-22 21:27:10 -07:00

10 lines
327 B
TypeScript

import type { HttpResponseHeader } from '@yaakapp-internal/models';
import { useMemo } from 'react';
export function useContentTypeFromHeaders(headers: HttpResponseHeader[] | null): string | null {
return useMemo(
() => headers?.find((h) => h.name.toLowerCase() === 'content-type')?.value ?? null,
[headers],
);
}