Live application with list of all shortened links: https://shortly-link.herokuapp.com/
This is a url shortener API, build with Ruby On Rails 6.
- Clone this repo to your local system.
- Execute
rails db:create
to create the database for the first time. - Execute
rails db:migrate
to migrate the database and create tables in your database. - Execute
yarn
to install frontend dependencies.
We have rake tasks to mimic the API calls, So to test the app do the following.
- Start your server with
rails server
.
To shorten a URL run following rake task.
rake app:encode URL=https://yourdesiredurl.com/
Result will be something like this:
- The shortened url of
https://yourdesiredurl.com/
ishttps://short.is/tkLo2367
To get original_url from the shortened url run the following rake task.
rake app:decode SHORTURL=https://short.is/tkLo2367
Result will be:
- The original url of short url
https://short.is/tkLo2367
ishttps://yourdesiredurl.com/
Shorten new URL:
- EndPoint -
/links
, POST - Params - { "link": { "url": "https://desiredurl.com/" } }
Get Original URL from shortened one:
- EndPoint -
/links/tkLo2367
, GET - Params - No params
List of all urls with their shortened urls. Pin a url and it will move at the top of list.
- All links have an attribute named
pinned
which isfalse
by default. - When a user pins a link, the
pinned
attribute changes totrue
. - And the list is ordered in descending order according to their
updated_at
time. - Hence the last pinned link will have higher
updated_at
value and will appear at top of list.
THANK YOU