Shortened url have to comply to certain format?

Regarding API & Microservices test number 3, does the shortened url have to follow certain rule/format, or it just need to be a simple unique integer id?

I will elaborate :

  • According to sample in the requirement description, the shortened url is actually just a simple integer prepended to the end route of my app. For example, the shortened url for www.freecodecamp.com is [this_project_url]/api/shorturl/3, where that last digit 3 is the actual shortened url.
  • But from reading various tutorials i can google, the shortened url is actually not that simple. For example in this tutorial, a shortened url of google.com is http://bit.ly/1bdDlXc . That is not shortened, it is actually gain more length (and harder to remember). There are other samples of solutions by fellow campers where the shortened url actually getting longer than the original url, therefore not shortened per definition.

The shortened url doesn’t actually have to be a number, it’s just a hint at one super-simple way you could implement it. The test only cares that it gets back a different URL and can roundtrip it back to the original URL. And if the “shortened” url turns out to be longer, so be it – even the existing URL shortening services will sometimes spit out a longer URL as you’ve noticed. The tests won’t care.

2 Likes