Back End Development and APIs Projects - URL Shortener Microservice

Tell us what’s happening:

My second and third test conditions are not passing, even though the code works perfectly as it should; redirects, and returns proper response.

You can check my code below

###Your project link(s)

solution: http://localhost:3000

githubLink: GitHub - OluwaFavour/url_shortener

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36

Challenge Information:

Back End Development and APIs Projects - URL Shortener Microservice

Is this challenge still unsolved?

Yeah… I read through the previous solutions on the forum, and my issue is different.

Even though it’s working as expected

Your URL validation isn’t working. Submit and look at the response in the browser dev tools (network tab).

The dns method only takes a hostname. You can use the URL constructor to get it.

new URL(url).hostname

It workeddd!!! :astonished::relieved:

Thanks for the tip lasjorg.
I just added the const hostname = new URL(url).hostname line like you said and passed it to the dns method instead of the hostname I got by splitting the url with the / seperator