Back End Development and APIs Projects - URL Shortener Microservice

Tell us what’s happening:
I’ve completed the challenge, but for the ftp:/john-doe.org test, the dns.lookup() didn’t consider the URL invalid, so I had to manually write in

if (!url.includes("http")) {
	res.json({error: "invalid url"});
}

My code: fcc-urlshortener - Replit

I guess my question is: Is there a better way to make sure this case fail?

Also if there’s any general problem with my solution, I’d love to know!

.
.
.

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0

Challenge: Back End Development and APIs Projects - URL Shortener Microservice

Link to the challenge:

The URL used is ftp:/john-doe.invalidTLD (we changed the tests a good while back).

new URL('ftp:/john-doe.invalidTLD').hostname
'john-doe.invalidtld'

If you pass that to dns.lookup it should fail.

1 Like