Files
yaak/src-web/hooks/useContentTypeFromHeaders.ts
2024-08-29 06:07:31 -07:00

10 lines
315 B
TypeScript

import type { HttpResponseHeader } from '@yaakapp/api';
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],
);
}