mirror of
https://github.com/hexastack/hexabot
synced 2024-11-24 04:53:41 +00:00
fix: improve error handling for invalid URL submission
This commit is contained in:
parent
37f20f7d79
commit
2da2552c3b
@ -25,6 +25,7 @@ import { ContentContainer } from "@/app-components/dialogs/layouts/ContentContai
|
||||
import { ContentItem } from "@/app-components/dialogs/layouts/ContentItem";
|
||||
import { Input } from "@/app-components/inputs/Input";
|
||||
import { ToggleableInput } from "@/app-components/inputs/ToggleableInput";
|
||||
import { URL_REGEX } from "@/constants";
|
||||
import { IMenuItem, IMenuItemAttributes, MenuType } from "@/types/menu.types";
|
||||
|
||||
export type MenuDialogProps = DialogProps & {
|
||||
@ -66,7 +67,8 @@ export const MenuDialog: FC<MenuDialogProps> = ({
|
||||
url: {
|
||||
required: t("message.url_is_invalid"),
|
||||
validate: (value: string = "") =>
|
||||
isAbsoluteUrl(value) || t("message.url_is_invalid"),
|
||||
(isAbsoluteUrl(value) && URL_REGEX.test(value)) ||
|
||||
t("message.url_is_invalid"),
|
||||
},
|
||||
payload: {},
|
||||
};
|
||||
|
@ -21,3 +21,6 @@ export const DATE_TIME_FORMAT = {
|
||||
|
||||
export const USER_DEFAULT_PICTURE =
|
||||
"https://avatars.dicebear.com/v2/identicon/6659e07058af581e68e33d05.svg";
|
||||
|
||||
export const URL_REGEX =
|
||||
/^(https?:\/\/)?((([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,})(:[0-9]{1,5})?(\/[^\s]*)?)$/i;
|
||||
|
Loading…
Reference in New Issue
Block a user