Files
hoppscotch/helpers/utils/contenttypes.js
2020-08-18 14:13:20 -04:00

28 lines
709 B
JavaScript

export const knownContentTypes = [
"application/json",
"application/vnd.api+json",
"application/hal+json",
"application/xml",
"application/x-www-form-urlencoded",
"text/html",
"text/plain",
]
export function isJSONContentType(contentType) {
if (contentType && contentType.includes(";")) {
const [justContentType] = contentType.split(";")
return (
justContentType === "application/json" ||
justContentType === "application/vnd.api+json" ||
justContentType === "application/hal+json"
)
} else {
return (
contentType === "application/json" ||
contentType === "application/vnd.api+json" ||
contentType === "application/hal+json"
)
}
}