export function isJsonContentType()

in libraries/azure-app-configuration-importer/src/internal/utils.ts [19:41]


export function isJsonContentType(contentType?: string): boolean {
  if (!contentType) {
    return false;
  }

  contentType = contentType.trim().toLowerCase();
  const mineType = contentType.split(";")[0].trim();
  const typeParts = mineType.split("/");
  if (typeParts.length != 2) {
    return false;
  }

  if (typeParts[0] != "application") {
    return false;
  }

  const subTypes = typeParts[1].split("+");
  if (subTypes[subTypes.length-1] == "json") {
    return true;
  }

  return false;
}