URL shortener project not passing tests 2 and 3

I have gotten all the functionalities done for the URL shortener microservice project, but still have tests #2 and #3 not working

This is a link to my project code :

https://replit.com/@ali-b-123/C5-P3#server.js

I last check your server with urlX = yahoo.com in req.body and it returned “invalid url”, may be the url checker is incorrect? yahoo.com is a valid url right? but cannot check further because I can’t start up the replit don’t know why.

1 Like

Yes it is a valid url, but if you test it with the proposed project by freecodecamp (https://url-shortener-microservice.freecodecamp.rocks/) it will also give “invalid URL”

Allright, I continue my testing and compare your replit with fcc replit, here are the comparison:

  1. when correct url input: http://www.wikipedia.org, fcc replit will give this and yours below, see the difference? I think it is caused by the usage of urlObject? just curious why you decided to create url object from url string, url string is enough it can be used directly as value in field original_url

fcc result:
Screenshot 2022-02-28 234215

your result:
Screenshot 2022-02-28 232530

  1. In case of invalid url, the response is different,

fcc response:
Screenshot 2022-02-28 234138

your response:

fcc use testing, the computer test your code, so difference in 1 character is considered incorrect by computer, be sure the format is correct, the field name is correct, etc,
I think this is my best guess,

Hope this help.

1 Like

Yes I think the slash (/) that is being put at the end of the URL is the problem, you are right. Concerning why I am using urlObject, that is because dns.lookup method does not accept a regular URL string (as far as I know).