Code Monkey home page Code Monkey logo

vanityurls's Introduction

logo

GitHub license Contributor Covenant All Contributors

vanityURLs is a simple solution to deploy a budget-friendly Url Shortener. It runs at scale in your Cloudflare subscription with continuous integration.

If you don't own an a Cloudflare subscription already, you can create your free account today so you can experience everything without spending a dime.

Features:

  • Fully branded internet domain using Cloudflare's DNS & Pages so your links are compact and pretty
  • URL redirection (301, 302, 303, 307 and 308)
  • Advanced redirection with splats (e.g., /news/* → /blog/:splat )
  • Continuous integration managed by Cloudflare Page Engine

My objective is to work at the command line and automate it. So feel free to fork, and customize.

What problem does it solve and why is it useful?

You’ve been there too, a fully branded short URLs is useful but your low volume does not justify a commercial solution. Furthermore, links generated by a free solution will eventually expire and they're not privacy friendly.

This kind of solution is known as TinyURL, tiny url, shorten that long URL, URL Shortening Service, goo.gl, bit.ly, short.io, etc.

It's bullet proof

As long as you secure your Github and Cloudflare accounts with robust authentication, there is not much that can go wrong with such simple solution. It use the products as designed, there is no hack involved.

Refer to how does it work for more information.

Setup

  1. Register a tiny internet domain name with your preferred vendor
  2. If you don't own an a Cloudflare subscription already, you need to create a free account
  3. Add the tiny internet domain name to Cloudflare DNS
  4. Follow the instructions to fork the GitHub repository and customize your setup
  5. Use the lnk bash script to shorten, personalize, and share fully branded short URLs with continuous integration on Cloudflare

Limitations

As this code is deployed on Cloudflare Pages, there are some product limits to be aware of:

  • A maximum of 2,000 static redirects and 100 dynamic redirects, for a combined total of 2,100 redirects (source).
  • The Free plan supports up to 500 automated builds per month (source).

Most of these limits wouldn't be reached in general use, but it's good to note for larger-scale deployments.

Platform-wise, the lnk scripts require bash and so are not natively compatible with Windows at this time.

Contributions

Contributions are welcome! We recognize all types based on the all-contributors specification. Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Benoît H. Dicaire
Benoît H. Dicaire

💻 📖 🛡️
Félix Léger
Félix Léger

🤔 📓 📣
Jake Edwards
Jake Edwards

📖
Tiago Serafim
Tiago Serafim

💻

Related

  • dnsConfiguration – Automated DNS configuration with StackOverflow's DNSControl and Git

Licence

vanityURLs is Copyright 2023 Benoît H. Dicaire and licensed under the MIT licence.

vanityurls's People

Contributors

allcontributors[bot] avatar bhdicaire avatar felleg avatar slig avatar xvii avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vanityurls's Issues

Administration via the CLI

  1. Generate a specific or a unique ID for a new URL
  2. Add the link to the local git repository
  3. Commit the change with an adequate description to the local git repository
  4. Push the change to GitHub

Cloudflare will detect the change and initiate a deployment 😄

lnk doesn't check if a URL already has an existing shortcode before adding to static.lnk

Steps to reproduce

$ echo "/felix https://felixleger.com"
$ bash bin/lnk https://felixleger.com

Expected behavior

# Randomized shortcode
$ bash bin/lnk https://felixleger.com
[Warning] "https://felixleger.com" is already being redirected with the following shortcode(s):
  - /felix
Do you want to continue creating a new random short code? (y/N):
Exiting without creating a new shortcode.

# Custom shortcode
$ bash bin/lnk https://felixleger.com /newcode
[Warning] "https://felixleger.com" is already being redirected with the following shortcode(s):
  - /felix
Do you want to continue adding "/newcode"? (y/N): 
Exiting without creting a new shortcode.

Actual behavior

[main c440f99] add redirect /H3H3H --> https://felixleger.com
 1 file changed, 1 insertion(+), 9 deletions(-)
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 12 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 346 bytes | 346.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
To gitlab.com:felleg/felx-cc.git
   0a8c789..c440f99  main -> main
Your shortened URL is https://felx.cc/H3H3H
Please give ~15 seconds for your link to become valid

$ cat static.lnk
/felix https://felixleger.com
/H3H3H https://felixleger.com

System configuration

Using commit b3dbf15

Instructions for adding yourself to the contributors list

Contributions are welcome! We recognize all types based on the all-contributors specification. Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Contributions

If you have contributed to the project in some way and aren't listed, please add a comment below for yourself by such as @all-contributors please add @bhdicaire for eventOrganizing, video, ideas, promotion

The bot will generate a PR that update .all-contributorsrc and README.md and I will take care of the merge.

Categories

a11y: ♿️
blog: 📝
bug: 🐛
code: 💻
design: 🎨
doc: 📖
eventOrganizing: 📋
example: 💡
financial: 💵
fundingFinding: 🔍
ideas: 🤔
infra: 🚇
maintenance: 🚧
mentoring: 🧑‍🏫
plugin: 🔌
projectManagement: 📆
promotion: 📣
question: 💬
research: 🔬
review: 👀
security: 🛡️
talk: 📢
test: ⚠️
tool: 🔧
translation: 🌍
tutorial: ✅
userTesting: 📓
video: 📹

Redirects don't work for websites with a hastag character

Steps to reproduce

./scripts/lnk https://example.com/#hashtag

This generates a short link. Visit the short link after ~20 seconds

Expected behavior

Get redirected to https://example.com/#hashtag

Actual behavior

Get redirected to https://example.com/#hashtag#hashtag

System configuration

Running from commit 7b06fe8b5b96c62494518b2379fd9eccddd951d4.

My conf:

# The path to your local copy of vanityURLs. For example,
# "~/Code/vanityURLs"
REPO_DIR="~/perso/felx-cc"

# Your tiny internet domain served by Cloudflare. For example,
# "dicai.re"
MY_DOMAIN="felx.cc"

# This variable is used by bin/tinyLnk. It determines how long your
# random code will be. For example, with SHORTCODE_LENGTH=5, your
# resulting URL could be something like "https://dicai.re/XXXXX" (5 X)
SHORTCODE_LENGTH=3

# Uncomment this value if you want to run the `lnk` and `tinyLnk`
# scripts in dry run mode, i.e. files will not be modified.
#DRY_RUN=true

LNK fail on macOS

Steps to reproduce

lnk add https://brew.sh

Expected behavior

It does not add a link to my static file

Actual behavior

/Users/bhdicaire/.vanityURLs.conf: line 6: ~/.config/bin/: No such file or directory
grep: invalid option -- P
usage: grep [-abcdDEFGHhIiJLlMmnOopqRSsUVvwXxZz] [-A num] [-B num] [-C[num]]
	[-e pattern] [-f file] [--binary-files=value] [--color=when]
	[--context[=num]] [--directories=action] [--label] [--line-buffered]
	[--null] [pattern] [file ...]
Error: Your input LONG_URL ('add') is invalid.
Hints:
- Does it start with 'http'?
- Does it contain a '.'?

System configuration

which lnk
/Users/bhdicaire/.config/bin/lnk
cat ~/.vanityURLs.conf 
# This file is your config for vanityURls to personalize and share branded URLs.
# For more info, visit https://github.com/bhdicaire/vanityURLs

# The path to your local scripts folder included in your path
# For example: ~/.config/bin
SCRIPT_DIR= "~/.config/bin/"

# The path to your local copy of vanityURLs.
# For example: ~/vanityURLs
REPO_DIR="/Volumes/Tarmac/codePublic/vanityURLs/v8s.link"

# Your tiny internet domain served by Cloudflare.
# For example: dicai.re or felleg.xyz
MY_DOMAIN="v8s.link"

# Your cloudflare's specific page URL.
# For example: vanityURLs.pages.dev
MY_PAGE="v8s-link.pages.dev"

# This variable determines how long your random code will be.
# For example, with SHORTCODE_LENGTH=3, your resulting URL
# could be something like "https://dicai.re/XXX" (3 X)
SHORTCODE_LENGTH=3

# Uncomment this value if you want to run the `scripts/lnk` script
# in dry run mode, i.e. files will not be modified.
#DRY_RUN=true
ls -1 /Volumes/Tarmac/codePublic/vanityURLs/v8s.link
build
dynamic.lnk
LICENSE
Makefile
README.md
scripts
static.lnk
vanityURLs.conf

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.