Back End Development and APIs Projects - URL Shortener Microservice

Tell us what’s happening:

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.

Your project link(s)

solution: boilerplate-project-urlshortener - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge Information:

Back End Development and APIs Projects - URL Shortener Microservice

It is your URL validation that is failing.

You are sending back {"error":"invalid url"} for the valid URLs the test is using.

POST Request:
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('').hostname
// ''
1 Like

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!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.