One thing I’d never done before was a URL shortener. Obviously there is no direct need for another one of these, but I thought I would add a bit of a twist: I’d use emoji characters. Already you should realize this has no practical purpose whatsoever.
After Twitter has been infested by these little and icons, I got interested in knowing more about them. As usual, all the best stuff is from Japan, but their use has become abundant, especially on social networks. If you are on a modern version of OS X on hardware, you already see them in every browser without an extension or plugin, excluding one really dumb exception. Why not see if I can push the envelope a bit by now using them in URLs? One awesome site has already made use of this as a domain name, using punycode. That got me started down the trail of what I’d need to make this a thing.
The bulk of the work was getting the URL->emoji and emoji/punycode-> URL logic working. I decided to do the naive implementation of just using a monotonically increasing id as the key, and then some nice CoffeeScript for the encode/decode functions. I had to of course modify the alphabet that this was using, and instead of the a-zA-Z0-9 alphabet, I used the emoji unicode characters. It was a matter of taking the hex codes from the unicode characters from here, putting them into the alphabet array, and then wrapping punycode encodes and decodes around getting the values from the alphabet array. Otherwise, the code is identical to the original source.
I needed a source for the previously mentioned integers for URL IDs, so it seemed that throwing sqlite3 and Sequelize into the app for persistence was a quick solution. Obviously this means I’d have to move to a full RDBMS should I have to have multiple web servers, but honestly who would want to use an emoji URL shortener?
I put the (really bad) code on GitHub for the halibut. The site is live at emoji.xyz. You’ll notice the link generated has the href pointed at the punycode version of the URL, while the text shows the actual emoticon. That’s mostly because many applications expectedly do not handle the emoji character, and set the location to the portion of the URL preceding the emoji character(s). Feel free to use the Textexpander as well, I created a gist for it here.