Coder Social home page Coder Social logo

shrt's Introduction

An URL Shortener

This project is my first attempt at a URL shortener. It's a simple web app that allows you to short any URL you want by API request. It's not perfect, but it's pretty good, I swear! It's also open source, so you can check out the code on this page.

Usage

Create a short URL

curl -X POST -H "Content-Type: application/json" -d '{"url":"example.com/mypath"}' https://s.x16.me/api/short

Get a short URL

curl -X POST -H "Content-Type: application/json" -d '{"short":"AAAAAA"}' https://s.x16.me/api/url

Redirect from a short URL

curl -IX GET https://s.x16.me/AAAAAA

shrt's People

Contributors

riprsa avatar

Stargazers

Sanaf avatar  avatar

Watchers

Yury Evtikhov avatar  avatar

shrt's Issues

Design Specification

This document serves as a basis for further development of the URL shortener project, outlining important requirements, assumptions and constraints.

Requirements

  1. The API server accepts a request with a given URL to return a unique ID string representing the provided URL.
  2. The API server by default accepts a request as a JSON object.
  3. The API server by default returns a non-error response as a JSON object.
  4. The API server returns the URL with host, path, query and fragment parts (per RFC 3986) in response to the ID string provided in the request.
  5. A specific API endpoint is responsible for returning HTTP 302 redirect response to the URL associated with the ID in the request.

Assumptions

  1. Invalid URL is validated server-side.
  2. It is the client's responsibility to specify necessary protocol for the returned URL.
  3. A specific API endpoint returns a HTTP 302 redirect when a valid ID stored earlier is requested as a path.

Example:

# `AAAAAA` maps to `example.com/somepath`
curl -IX GET https://s.x16.me/AAAAAA
HTTP/1.1 302 Found
Location: https://example.com/mypath

Constraints

  1. Protocol (scheme) is not stored as a part of the provided URL.
  2. Protocol (scheme) is not returned in the URL response.
  3. User identification (the user:password@ part) is not stored in the provided URL.
  4. User identification (the user:password@ part) is not returned in the URL response.
  5. When HTTP 302 redirect is returned, only HTTPS protocol is used in the Location header of the response.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.