URL Shortener MicroService - Not Passing 2/4 test

Tell us what’s happening:
I am trying to compete the URL Shortener Microservice project, for back end development. I can pass all of the test when I try them myself, but when I submit the URL, it won’t pass 2/4 test. These are the two test,
–You can POST a URL to /api/shorturl and get a JSON response with original_url and short_url properties. Here’s an example: { original_url : 'https://freeCodeCamp.org', short_url : 1}

–When you visit /api/shorturl/<short_url> , you will be redirected to the original URL.

Your project link(s)

solution: https://replit.com/@razemnuj/boilerplate-project-urlshortener#server.js

Your browser information:

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

Challenge: URL Shortener Microservice

Link to the challenge:

1 Like

I’m also facing this same problem ! And I don’t know how to continue My file on replit

@MarcosGTS

I would log out url and name to see if you are not making assumptions about the URL that might not be true. And make sure you are only providing dns.lookup with a hostname (i.e. no paths). It is also worth noting that the invalid URL being used when stripped to just the hostname will pass as a valid URL (you can also look at the tests if that helps).

You might also look at some other ways of getting the hostname and protocol
https://nodejs.org/api/url.html#url_url

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