URL Shortener Microservice 4th test doesn't pass

I finished this challenge, but the validation test doesn’t work, tho it’s functionally working on my browser (I’m getting {“error”:“invalid url”})

I used Regex for this:
let urlRegex = new RegExp(/[-a-zA-Z0-9@:%.+~#=]{1,256}.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%+.~#?&//=]*)?/gi);

if (!inputUrl.match(urlRegex)){
return res.json({ error: “invalid url” });

What’s wrong?

Challenge: URL Shortener Microservice

Link to the challenge:

can it say invalid url for an url like ftp://www.google.it?

Try using dns.lookup() method for URL validation. It worked fine for me. You have to pass it URL like this www.google.com or google.com. URL shouldn’t be like https://www.google.com coz this URL is considered invalid by it. My implementation is something like this

dns.lookup(<Your_url>, (err) => {
    if (err) // Handle error
    else {
      // Save it to database with generate short url