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
-9
View File
@@ -36,7 +36,6 @@
"react-scrollbars-custom": "^4.1.1",
"react-signature-canvas": "^1.0.6",
"reactour": "^1.19.1",
"validator": "^13.11.0",
"web-vitals": "^2.1.4"
}
},
@@ -20503,14 +20502,6 @@
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz",
"integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A=="
},
"node_modules/validator": {
"version": "13.11.0",
"resolved": "https://registry.npmjs.org/validator/-/validator-13.11.0.tgz",
"integrity": "sha512-Ii+sehpSfZy+At5nPdnyMhx78fEoPDkR2XW/zimHEL3MyGJQOCQ7WeP20jPYRz7ZCpcKLB21NxuXHF3bxjStBQ==",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
@@ -32,7 +32,6 @@
"react-scrollbars-custom": "^4.1.1",
"react-signature-canvas": "^1.0.6",
"reactour": "^1.19.1",
"validator": "^13.11.0",
"web-vitals": "^2.1.4"
},
"scripts": {
@@ -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;
}
};