Invalid URL JSON response test not passing

URL Shortener Microservice Challenge

If the URL is invalid, I wrote,

res.send({ error: 'invalid url' });

I do get the proper error, but it shows up as
{"error":"invalid url"} on the page. But since the test required the error to show up like this { error: 'invalid url' }, I suspect it is a matter of format.

How do I properly format the JSON data so it shows up the way they want it? Otherwise, I have no idea why that test failed, since they don’t provide their inputs and expected outputs.

Thank you!

My project links
githubLink: GitHub - brpasiliao/boilerplate-project-urlshortener: A boilerplate for a freeCodeCamp project.
solution: https://replit.com/@brpasiliao/boilerplate-project-urlshortener

My browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36

Your isValidUrl will not throw with the invalid URL that is passed by the tests

ftp:/johndoe.org.


I agree it is very unclear what constitutes an invalid URL based on the requirement. There is an issue where it was suggested to change the message of the requirement to include the invalid URL. Which I would be in favor of.

If you want you can create the PR with the change to the requirement as suggested in the last post in the issue.