link

Use Git commit message to store the short URL on GitHub, host the redirector on GitHub Pages

This interesting tool is from the article: https://www.v2ex.com/t/1105845

How it works?

branch description
page 404.html redirector
url store URLs

The GitHub API currently(2025.2.1) allows the request to specify the Git commit in two simpler ways than the full SHA-1 hash 9fc3741bbf92219dd53278f447e124d2d3fdf5df:

It’s impossible to redirect the short URL using index.html on GitHub Pages, because it only serves the root path /, other requests will respond 404.html

---
config:
  theme: neutral
  mirrorActors: false
---
sequenceDiagram
    %% autonumber
    Broswer ->>+ liqwang.github.io: GET /9fc3
    liqwang.github.io ->>- Broswer: 404.html
    Broswer ->>+ api.github.com: GET /commits/9fc3
    api.github.com ->>- Broswer: target URL
    Broswer ->> target website: redirect

TODO