url validation

This commit is contained in:
Arjun Patel
2022-02-14 11:09:38 -08:00
parent 8d9b33e72c
commit d945f86a1e
@@ -8,6 +8,7 @@ import { useRecoilValue } from "recoil";
import { useAuth } from "../../contexts/authContext"; import { useAuth } from "../../contexts/authContext";
import { selectedConvoAtom } from "../../recoil/main"; import { selectedConvoAtom } from "../../recoil/main";
import LinkIcon, { getFavicon } from "./LinkIcon"; import LinkIcon, { getFavicon } from "./LinkIcon";
import isValidHttpUrl from "@nirvana/common/helpers/urlHelper";
export default function CreateItemModal(props: { export default function CreateItemModal(props: {
pastedLink: string; pastedLink: string;
@@ -54,6 +55,12 @@ export default function CreateItemModal(props: {
return; return;
} }
if (!isValidHttpUrl(linkVal)) {
toast.error("not a valid url");
setLoading(false);
return;
}
// service to add link to the collection // service to add link to the collection
// change the cacheddraweritem on the convo doc // change the cacheddraweritem on the convo doc
const newLink = new Link(linkDesc, linkVal, currUser!.uid); const newLink = new Link(linkDesc, linkVal, currUser!.uid);