https://github.com/knightchaser/urlshortener
A simple URL shortener inspired from <System Design Interview>
https://github.com/knightchaser/urlshortener
Last synced: about 2 months ago
JSON representation
A simple URL shortener inspired from <System Design Interview>
- Host: GitHub
- URL: https://github.com/knightchaser/urlshortener
- Owner: KnightChaser
- Created: 2024-03-02T15:40:34.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-03T08:37:22.000Z (over 2 years ago)
- Last Synced: 2025-01-28T16:46:17.986Z (over 1 year ago)
- Language: JavaScript
- Size: 149 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# urlshortener


### A very very simple URL shortener inspired from ``
### Appearances


### Mechanism
1. Do SHA256 hash URL
2. Encode hashed URL to BASE62 encoding
3. Cut the first 10 characters. The duplication probability is **1/62^10** = 1/839,299,365,868,340,224. The url will be like `W99EdQi0CY`
4. Save that to the database and return the shortened URL to the user after appending the site domain like `knig.ht/W99EdQi0CY`. (Refer to `.env` file.)
It's a very simple and rough implementation, I just built it in only 3 hours. Of course, not for real production!