how to read valid url in javascript new URL() code example
Example 1: how to read valid url in javascript new URL()
function isValidHttpUrl(string) {
let url;
try {
url = new URL(string);
} catch (_) {
return false;
}
return url.protocol === "http:" || url.protocol === "https:";
}
Example 2: validate url in javascript
validate url
Example 3: validate url javascript
validateurl