contenttypes.ts 501 B

1234567891011121314151617
  1. export const knownContentTypes = {
  2. "application/json": "json",
  3. "application/ld+json": "json",
  4. "application/hal+json": "json",
  5. "application/vnd.api+json": "json",
  6. "application/xml": "xml",
  7. "application/x-www-form-urlencoded": "multipart",
  8. "multipart/form-data": "multipart",
  9. "text/html": "html",
  10. "text/plain": "plain",
  11. }
  12. export type ValidContentTypes = keyof typeof knownContentTypes
  13. export function isJSONContentType(contentType: string) {
  14. return /\bjson\b/i.test(contentType)
  15. }