Skip to content
This repository has been archived by the owner on Jan 31, 2023. It is now read-only.
/ urlshortener Public archive

🔗 A simple url shortener.

License

Notifications You must be signed in to change notification settings

xPaw/urlshortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a very basic url shortener. It uses HashIds to encode the id.

Shortening an url

Send a POST request with form data to /@create that contains two fields:

  • secret - The secret token defined in config.
  • url - Url to shorten.

Upon success it will return HTTP 201 and the shorted link will be in Location header, as well as in the body.

If an error occurs, it will return HTTP 400 instead, and body will contain the error.

  • Urls may not contain new lines.
  • Urls must pass with parse_url.
  • Urls must have a host.
  • Urls must use https:// scheme.

Example request:

curl https://example.com/@create -X POST -F 'secret=FOOBAR' -F 'url=https://example.com'

About

🔗 A simple url shortener.

Resources

License

Security policy

Stars

Watchers

Forks

Languages