[URL Shortener Project] Everything works, but failing two tests

I have written up the code for the URL shortener and it appears to work well with different input URLs; however, when submitting it fails for the two main tests: shortening and redirecting.

I initially thought it was an issue of the database not being initialized when the tests run, but now all my code is within a callback function that runs once the database connection is open. The tests still fail (despite working).

My code can be found here: https://repl.it/@kayloody/FCC-API3#server.js

A running version here: https://FCC-API3.kayloody.repl.co

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

Challenge: URL Shortener Microservice

Link to the challenge:

Hello there,

Thanks for bringing this up. I think since, you started the project, it has been updated. I have spotted a mistake in the tests, and am confirming it now:

Until this is resolved, I suggest you not use the dns library for any validation. This should allow you to pass the tests.

1 Like

Hi Sky

Thank you very much for your reply. It was indeed an issue with the tests.

I ended up resolving it by using the URL library for validating the link (instead of DNS) as you have suggested. It did require additional lines of code (including to test for HTTP/HTTPS protocols).

Thanks again!

(Updated code is available at the links above for those interested)

2 Likes