So i have tested my code for this project both with Postman and on the projects index.html file. In both cases the code is doing what is expected. So i am unsure what the running tests are expecting from the code. Any help is appreciated.
You are sending back {"error":"invalid url"} for the valid URLs the test is using.
POST Request: https://boilerplate-project-urlshortener.chriskmamo.repl.co/?v=1698951971952
Response: {"error":"invalid url"}
Use the browser dev tools and look at the network request/response when you submit.
If you want the hostname from a URL you can use the URL constructor.
new URL('https://forum.freecodecamp.org/t/back-end-development-and-apis-projects-url-shortener-microservice/648273').hostname
// 'forum.freecodecamp.org'
Thank you that solved my problem. As you said my URL validation was failing because i did not remove url queries from the raw request url. This lead to the dns.lookup giving an error. The suggested URL constructor worked beautifully and simplified my code. Thank you!