Skip to content

joeinnes/url-shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Joe's URL Shortener

A simpler implementation of https://github.com/nelsontky/gh-pages-url-shortener using simple files

To use yourself, add files in the 'links' directory with the name of the short link (eg: "test" will become <your_url_here>/test

Configure GH Pages to use 'main' and you are done.

How does this work?

Adapted from @kidGodzilla's explanation here.

  1. CNAME points URL to gh-pages branch
  2. 404.html handles all requests
  3. Small javascript snippet tries to fetch the file at /links/<short_link>. If it's found, it'll redirect the user to whatever is in the file.
  4. Profit?

Sidenote for security

There's no safety checking on the fetched file, so XSS is possible using this tool. Make sure you are in control of the repository, and you don't accept PRs without proper review (see https://link.joeinn.es/xss from https://github.com/joeinnes/url-shortener/blob/main/links/xss).

Also, obviously, this tool does not check the safety of the site you're redirecting to. Malware etc. could theoretically be deployed through this URL shortener.

About

A simpler implementation of https://github.com/nelsontky/gh-pages-url-shortener using a config file

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages