We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
The URL
object in JavaScript provides a built-in way to parse and validate URLs. It is robust, handles complex cases, and doesnβt require writing or maintaining custom regular expressions neither does it require an external library.
function isValid(url) {
try {
new URL(url);
return true;
} catch (e) {
return false;
}
}
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.