Live data from Hacker News

Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

github.com

161–170 of 182 posts

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#161

Earlier quoted context omitted.

A URL shortener can be done with no database - I did it using only Lambda functions once, but I wouldn't recommend it. :) https://kevinkuchta.com/2018/03/lambda-only-url-shortener/

I've seen people suggest using pi as a "database." In this instance you could map ranges of pi to characters. Then you search pi until you find the right range. The URL would contain the range(s) needed. This is terrible and so computationally wasteful. But it's interesting to think about.

On average the resulting URLs would be as long (or longer) as the original. You can’t cheat entropy.

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#162

> Unlike many URL shorteners, this one does not need a database and can be entirely hosted on GitHub pages. it does need a database though. it just uses someone else's database

A URL shortener can be done with no database - I did it using only Lambda functions once, but I wouldn't recommend it. :) https://kevinkuchta.com/2018/03/lambda-only-url-shortener/

A more obvious way would be to get the shortened part of the URL via "random" bits extracted by hashing the input URL.

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#163
I made a shortener using nginx and a config file: https://statico.link

It uses a tab-delimited nginx map file as a config. To make changes, I wrote a tiny shell wrapper which opens the config in Vim, checks it in, and reloads nginx: https://statico.link/how

People frequently asked me for a list of all of the links, so I wrote a tiny server to serve them: https://github.com/statico/statico-link-list

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#164
Bad for so many reasons (including abuse of GitHub issues, spam, and the ability to change the URL the short link points to)

If you want your own private shortener, I have a better idea:

Use GitHub Pages and create a `/1/index.html` (where 1 is the short link name) and add a “refresh” meta tag in it. Completely static and no build/JS necessary.

This could be opened up to others by combining it with issues and GitHub Actions, but who wants that?

Another better idea for a private URL shortener is hardcoding a list of URLs in a CloudFlare Worker. Much faster and with real 301 redirects.

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#165

Earlier quoted context omitted.

I've seen people suggest using pi as a "database." In this instance you could map ranges of pi to characters. Then you search pi until you find the right range. The URL would contain the range(s) needed. This is terrible and so computationally wasteful. But it's interesting to think about.

Seems technically possible - example.com/12_3456 would calculate out pi, read 12 digits starting at position 3456, then convert those digits to ascii and you'd have your result. Given how far into the digits pi you'd have to go to find the exact right sequence that matches, eg, https://google.com , though, I suspect the resulting position number would be longer than the original url! Also, conceptually, it seems like…

You could add a short one or two character long identifier that changed the digits-of-pi to ascii map then select the mapping that results in the lowest index. In this case part of the "database" would exist within the URL shortener itself.

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#166
post #24

Earlier quoted context omitted.

HAHA so that was you. That was a good one! Yes and that title is definitely slightly misleading I kinda didn't want it to get so long and wanted that slight clickbait effect. Yep I actually cannot control the status code at all. Part of what made this a fun and hacky project was the fact that I was actually redirecting to the actual URLs by catching the 404s. So, the only way i could think of catching the infinite lo…

Indeed :) I think you could catch the infinitive loop client-side as well by comparing what the URL to redirect to is, and comparing it with the current URL. If they are the same, prevent the redirect. Although you would still be able to create loops by using two issues instead. Maybe just comparing the full hostname? If it's nlsn.cf, don't redirect.

> Maybe just comparing the full hostname? If it's nlsn.cf, don't redirect.

Doesn't work; eg, make http://someothershorten.er/foo -> http://nlsn.cf/1234 -> http://someothershorten.er/foo.

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#167

Earlier quoted context omitted.

A URL shortener can be done with no database - I did it using only Lambda functions once, but I wouldn't recommend it. :) https://kevinkuchta.com/2018/03/lambda-only-url-shortener/

A more obvious way would be to get the shortened part of the URL via "random" bits extracted by hashing the input URL.

How would you map the short URL back to the original?

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#168
post #129

I was always fixated with URL shorteners and always wanted to write one myself. While it would be easy to write one that works with a server, I loved the idea of hosting and running one for free. Thus, I wrote this URL shortener which does not need a backend to work at all. It uses GitHub issues as a "database", and unlike most other URL shorteners that do not need backends, this one doesn't need a # prefixed to the…

"I was always fixated with URL shorteners and always wanted to write one myself. While it would be easy to write one that works with a server, I loved the idea of hosting and running one for free." I felt exactly the same way and did, in fact, build one.[1] It was pretty simple. There's an interesting twist to the particular one I built - it's not specifically a URL shortener, it's a "Universal Shortener".[2] Also no…

My biggest problem with this is the domain name. If you say "oh by", a vanishingly small amount of people will translate this to "0x". And you can't say "oh ex dot co", because the URL has both a 0 and a O in it - which will also always be ambiguous when written down. So you have to say something like "zero ex dot co", which I suppose is fine, but it has a lot of extra syllables.

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#169

I made a shortener using nginx and a config file: https://statico.link It uses a tab-delimited nginx map file as a config. To make changes, I wrote a tiny shell wrapper which opens the config in Vim, checks it in, and reloads nginx: https://statico.link/how People frequently asked me for a list of all of the links, so I wrote a tiny server to serve them: https://github.com/statico/statico-link-list

Sweet! I thinkg something similar could be achieved by just writing an nginx plugin.
Post reply on HN