feat: segmented content-type dropdown UI (#2382)

Co-authored-by: liyasthomas <liyascthomas@gmail.com>
This commit is contained in:
Nivedin
2022-05-31 17:04:05 +05:30
committed by GitHub
parent eb6c4f1a05
commit 39f72f8458
3 changed files with 71 additions and 16 deletions

View File

@@ -14,6 +14,37 @@ export const knownContentTypes: Record<ValidContentTypes, Content> = {
"text/plain": "plain",
}
type ContentTypeTitle =
| "request.content_type_titles.text"
| "request.content_type_titles.structured"
| "request.content_type_titles.others"
type SegmentedContentType = {
title: ContentTypeTitle
contentTypes: ValidContentTypes[]
}
export const segmentedContentTypes: SegmentedContentType[] = [
{
title: "request.content_type_titles.text",
contentTypes: [
"application/json",
"application/ld+json",
"application/hal+json",
"application/vnd.api+json",
"application/xml",
],
},
{
title: "request.content_type_titles.structured",
contentTypes: ["application/x-www-form-urlencoded", "multipart/form-data"],
},
{
title: "request.content_type_titles.others",
contentTypes: ["text/html", "text/plain"],
},
]
export function isJSONContentType(contentType: string) {
return /\bjson\b/i.test(contentType)
}