summaryrefslogtreecommitdiffstats
path: root/docusaurus/src/functions/submitMathInputForm.ts
blob: cf3294bf281d7758eaf2a92514705e9b8245bda0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* 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);
};