Skip to content

Commit

Permalink
feat(host): add possibility to add host domain without ssl
Browse files Browse the repository at this point in the history
  • Loading branch information
Stéphane committed Oct 11, 2023
1 parent bf55263 commit 4d86856
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/components/ModalAddCustomInstance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ import { Settings } from "../types/interfaces/Settings";
import { useSetSettings } from "../providers/Settings";
import { Instance } from "../types/interfaces/Instance";

const DOMAIN_REGEX =
// eslint-disable-next-line no-useless-escape
/^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/gm;
const URL_REGEX = new RegExp(
"^(https?:\\/\\/)?" + // Protocol
"((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|" + // Domain name
"((\\d{1,3}\\.){3}\\d{1,3}))" + // Ip (v4) address
"(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*" + // Port and path
"(\\?[;&a-z\\d%_.~+=-]*)?" + // Query string
"(\\#[-a-z\\d_]*)?$",
"i"
);

export const ModalAddCustomInstance = memo(() => {
const [opened, setOpened] = useState(false);
Expand All @@ -34,7 +40,7 @@ export const ModalAddCustomInstance = memo(() => {
isDefault: false,
},
validate: {
domain: (value) => !value.match(DOMAIN_REGEX),
domain: (value) => !value.match(URL_REGEX),
},
});
const setSettings = useSetSettings();
Expand Down Expand Up @@ -99,7 +105,10 @@ export const ModalAddCustomInstance = memo(() => {
<Select
label="Type"
{...form.getInputProps("type")}
data={[{ label: "https", value: "https" }]}
data={[
{ label: "https", value: "https" },
{ label: "http", value: "http" },
]}
/>
<Space h="lg" />
<Checkbox label={t("default")} {...form.getInputProps("isDefault")} />
Expand Down

0 comments on commit 4d86856

Please sign in to comment.