Back End Development and APIs Projects - URL Shortener Microservice

My URL Shortener seems to work for me but doesn’t pass the tests.

Do you have any idea what could be the issue? Perhaps I’m not treating queries the right way?

githubLink: GitHub - dmgodoy/freecodecamp-project-urlshortener: A boilerplate for a freeCodeCamp project.
solution: freecodecamp-project-urlshortener - Replit

Your browser information:

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

Challenge: Back End Development and APIs Projects - URL Shortener Microservice

Link to the challenge:

Your urlValidator class does not work properly.

I submitted a valid url (see below) to your api and it responds with {"error":"invalid url"}

https://freecodecamp-project-urlshortener.rmdawson.repl.co

1 Like

Thanks a lot! That fixed the issue and I was able to pass the tests!

Cheers.

You may have passed the tests, but your urlValidator’s regex does not work.

I should be able to put as many dots between letter/number substrings and still be a valid url.

For example, all of the following are valid but your app would say they are not:

https://freecodecamp-project-urlshortener.one.rmdawson.repl.co

https://freecodecamp-project-urlshortener.one.two.rmdawson.repl.co

https://freecodecamp-project-urlshortener.one.two.three.rmdawson.repl.co

https://freecodecamp-project-urlshortener.one.two.three.four.rmdawson.repl.co

and so on…

Hi Randell.

I think it was fine. Keep in mind I do url validation and after dns lookup. I believe that is the reason those URL fail.

Thanks again!!

No, I believe it is the regex. How did you get the url I replied with to pass? Did you modify the regex?

Yes, I modified the regex. You can find the validator here:

https://replit.com/@damedina/freecodecamp-project-urlshortener#urlvalidator.js

It seems to work properly to me (see quick test below):

https://replit.com/@damedina/FreecodecampUrlValidatorTest#index.js

Cheers!

Regardless, your app is not meeting the requirements. You should refactor you app to handle these urls and longer ones (more .xyz.abc.123 etc.).

When I submit:
https://freecodecamp-project-urlshortener.one.rmdawson.repl.co the response is:
{"error":"invalid url (dns lookup)"}

When I submit:
https://freecodecamp-project-urlshortener.one.two.rmdawson.repl.co the response is: {"error":"invalid url (dns lookup)"}

When I submit:
https://freecodecamp-project-urlshortener.one.two.three.rmdawson.repl.co the response is: {"error":"invalid url (dns lookup)"}

When I submit:
https://freecodecamp-project-urlshortener.one.two.three.four.rmdawson.repl.co the response is: {"error":"invalid url (dns lookup)"}

Hi Randell.

Sorry, I don’t understand what your point is.

The provided urls fail the dns.lookup test, that’s why my app returns {“error”:“invalid url (dns lookup)”}.

Isn’t that the expected behavior?

Cheers!