a simple url shortener for cloudflare workers
Find a file
2023-09-17 07:38:21 +10:00
.github/workflows fixed workflow name 2023-09-17 07:38:21 +10:00
src added deploy button and github action deploy 2023-09-17 06:34:37 +10:00
.gitignore Initial 2023-09-17 04:52:02 +10:00
package.json Initial 2023-09-17 04:52:02 +10:00
README.md updated readme 2023-09-17 07:33:41 +10:00
test.py fixed tests, added to deploy 2023-09-17 07:19:04 +10:00
wrangler.toml fixed custom domain 2023-09-17 07:01:36 +10:00

linkie

A simple url shortener. Largely adapting VandyHacks/vhl.ink with the aim of providing a more ptpb-like experience (i.e the fewest keystrokes from a cli possible while still being reasonably secure for private use)

Deploy to Cloudflare Workers

Deploying

Come up with a username:password, base64 encode them, add them to a secret as AUTH_KEY = Basic $secret, create a new KV namespace called KV, then wrangler deploy

Alternatively, get your AUTH_KEY, click the Deploy to Cloudflare Workers button above, once it's forked the repo go there and set up your Actions secrets and variables in Settings > Security, with AUTH_KEY and CF_API_TOKEN as secrets and DEPLOY_HOST as the domain you're hosting linkie on (defaulting to https://linkie.your-username.workers.dev)

Usage

curl -n -d u=http://example.com linkie/path will make http://linkie/path 302 redirect to the provided url. use .netrc to store the auth username/password (inspired by ix.io). Yes it supports emoji

curl -n -F 'u=<-' linkie/path will make the path 302 redirect to the url provided on stdin. Doesn't support more than one url or anything that's not a url. For instance:

curl -F 'u=<-' linkie/_ <<EOF
http://example.com
http://example.com?2
EOF
linkie/path => http://example.comhttp//example.com?2

curl -n -d u=http://example.com linkie/_, if you provide an underscore as the path linkie will generate a four character path from a-z0-9. if it has a collision five times in a row it'll return 500.. at that point i'd probably increase the length of the random ids in the function at the top of index.js to 5 or something, and also i should get off the internet because i've generated 36^4 short urls with this service and that's insane

See test.py for more usage and test cases