summaryrefslogblamecommitdiffstats
path: root/docusaurus/src/functions/submitMathInputForm.ts
blob: cf3294bf281d7758eaf2a92514705e9b8245bda0 (plain) (tree)






















                                                                   
/* SPDX-License-Identifier: AGPL-3.0-or-later */

import React from "react";

export default (event: React.FormEvent<HTMLFormElement>): void => {
  event.preventDefault();
  const htmlFormElement = event.currentTarget;
  const formData = new FormData(htmlFormElement);
  const i = formData.get("i");

  const url = new URL("/input/", window.location.href);

  if (typeof i === "string") {
    url.searchParams.set("i", i);
  } else if (i instanceof File) {
    console.warn({ i });
  } else {
    const typescriptExhaustivenessCheck: never = i;
    console.warn({ typescriptExhaustivenessCheck });
  }

  window.location.assign(url);
};