export function json_mime_add(headers: Headers): Headers {
  headers.set("Content-Type", "application/json");
  return headers;
}

export function cors_add(headers: Headers): Headers {
  headers.set("Access-Control-Allow-Origin", "*");
  return headers;
}

export function substitute_base_name_(
  pattern: string | RegExp,
  replace_with: string,
  bytes: Uint8Array<ArrayBuffer>,
): string {
  const decoder = new TextDecoder();
  const text = decoder.decode(bytes);

  return text.replace(new RegExp(pattern, "g"), replace_with);
}
