Open source short URL maker
Fork this repo.
To fork this repository and use it for yourself:
- Fork the repository on GitHub.
- Clone the forked repository to your local machine.
- Update the
CNAME
file with your custom domain (if you have one). - Update the
BASE_URL
andTOKEN
constants inindex.html
with your GitHub repository details and a personal access token. - Update the API call where this comment is located:
Update "USERNAME" and "REPOSITORY" respectively
- Enable GitHub Pages for your repository.
- Push your changes to the
main
branch.
This project is a proof of concept for a URL shortener that uses GitHub Actions to create short versions of URLs. The main components are:
- index.html: The main web page where users can enter a URL to shorten. It includes a form to input the long URL and a button to generate the short URL. The page also handles redirection based on the short URL code.
- data/urls.js: A JavaScript file that stores the mappings between short URLs and long URLs.
- .github/workflows/update-url-mappings.yml: A GitHub Actions workflow that processes new URL entries from GitHub issues and updates
data/urls.js
with the new mappings.
- index.html: Contains the HTML structure and JavaScript code to handle URL shortening and redirection. The
shortenURL
function sends a request to create a new GitHub issue with the long URL and the generated short code. ThehandleRedirect
function checks if a short code is present in the URL query parameters and redirects to the corresponding long URL if found. - data/urls.js: Stores the URL mappings in a JavaScript object format.
- .github/workflows/update-url-mappings.yml: Defines a GitHub Actions workflow that triggers when a new issue is opened. It extracts the short and long URLs from the issue body, updates
data/urls.js
, and commits the changes back to the repository.
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License. You are free to use and copy this work, but not for commercial purposes.
© 2024 Grant Hendricks.