summaryrefslogtreecommitdiffstats
path: root/docusaurus/src/functions/submitMathInputForm.ts
blob: bb7c34e824f7aa4c36d5d102d5b0bd738233397e (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";
import typescriptNever from "./typescriptNever";

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 {
    typescriptNever(i);
  }

  window.location.assign(url);
};