Replace npm package with manual valiadation

This commit is contained in:
rishabjasrotia
2023-11-22 18:57:18 +05:30
parent 3992a9be94
commit 1b3508a9ef
3 changed files with 6 additions and 12 deletions
@@ -1,5 +1,4 @@
import axios from "axios";
import validator from 'validator';
export async function getBase64FromUrl(url) {
const data = await fetch(url);
@@ -303,5 +302,10 @@ export const contactBook = async (objectId) => {
// function for validating URLs
export function urlValidator(url) {
return validator.isURL(url);
try {
const newUrl = new URL(url);
return newUrl.protocol === 'http:' || newUrl.protocol === 'https:';
} catch (err) {
return false;
}
};