Please test my project, somehow fails on FCC

Tell us what’s happening:
I get all required responses (doing it without mongoose as it is not mandatory), however still have the problems for passing the tests. Could you please review my project?
Your project link(s)
URL shortener

solution: https://farid-urlshortener.glitch.me

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36.

Challenge: URL Shortener Microservice

Link to the challenge:

Hello there,

There seems to be a server error with the app, because, whenever I submit the tests I see status 500 errors in the browser console.

Otherwise, this is not the correct use of the dns.lookup function:

const url = (submittedUrl.split("//"))[1];
        dns.lookup(url,(err,addresses,family)=>{

dns.lookup accepts only a domain as the first argument.

Hope this helps

But here it is also accepting only one argument, which is url, the next is the callback function

What I am saying is that the value of url is not what dns.lookup wants in its first argument. Example:

  • For an input of https://example.com/test-page/
  • url === 'example.com/test-page/'
  • dns.lookup expects only the domain as the first argument.
  • 'example.com' is the domain. 'example.com/test-page/' is not only the domain.

Hope this clarifies

I checked it with the correct domain format as you have described. Still no luck, checked the server with the postman post request using x-www-form-urlencoded, passes without any problem, however still no luck on freecodecamp test cases. Thanks for the time :slight_smile:

Try logging out req.body in the POST route.

I would also suggest using the repl.it starter project instead and leaving the index.html file alone and not changing it.

Still the same problem.
Repl.it link

Log out the submittedUrl and the check.

console.log(submittedUrl)
const check = submittedUrl.match(/^https:\/\/www\./g)?true:(submittedUrl.match(/^http:\/\/www\./g)?true:false);
console.log(check)

I looked at the console.log as you adviced, don’t see any problem, still fails in fcc tests
console

Hello there,

Just so you know, the tests use your app’s URL to test the functionality:
https://boilerplate-project-urlshortener.faridhuseynov.repl.co/<some_unique_number>

Here are the tests:

Hope this helps

Try submitting it instead and look at the logs.


Also, the dns.lookup will fail as well. Create a simple Nodejs repl and test the URL you get back from the split. Look at the URL, it has to just be the host name (and nothing more).

https://nodejs.org/api/dns.html#dns_dns_lookup_hostname_options_callback

1 Like