I need to verify a submitted URL by excluding any additional paths from it.
Here is the URL that the user submitted:
const inputUrl = document.getElementById("inputVal").value;
If the user submits 'http://example.com/faq'
, I want to write an if/else statement that checks only for 'example.com', regardless of whether it's using 'http/https' or has any extra paths after '.com'
if (inputUrl == "example.com") {
console.log ("This is example.com");
} else {
console.log("This is not example.com");
}
Any guidance on this matter would be highly appreciated.