Back End Development and APIs Projects - URL Shortener Microservice

Tell us what’s happening:
My solution passes all test cases except the last one:

If you pass an invalid URL that doesn’t follow the valid format, the JSON response will contain { error: ‘invalid url’ }

Trying it manually, it worked just fine. Can someone kindly help me out?

Your project link(s)


githubLink: GitHub - codeHokage1/fcc_urlShortener_microservice

Your browser information:

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

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

Link to the challenge:

An important part of programming is testing the code so its outcome is as you expected to be.
Can you type a couple of examples of invalid URL you have tried so far?

Another thing I have noticed is that when I keep inserting the same URL over and over again, it’s short version keeps changing as well. That’s a waste of storage space, don’t you think?

const url = require('url').URL;

const url2 = new url(urlToShorten);

You are relying on a functionality of the URL module which relies on a correct input
and is not solely made for a purpose of verifying correct web address URL.

The required format is or
but your API also accepts URL like C://hello.txt.

You need to ensure that the format is correct yourself. And when you do that, you don’t even need the url module for that.


Thank you very much for pointing that out.
I have been able to correct it and it passes the test now

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.