URL Shortener powered by Google Apps Script
Build a URL Shortening service powered by Google Apps Script and hosted using GitHub Pages.
have you ever wondered no matter how beautiful your web app may seem, the apps script "url" always takes away some of its charisma?
the long form url has always bothered me but that wasn't my inspiration to start working on building a url shortening service that uses the resources available with apps script. technically, it all started when I came across jonathon broughton's technique to use apps script web apps within embeded ifames in github pages, which got my gears turning for i'd been jonesing to make use of an undocumented parameter within apps script's doGet
function - pathInfo
; which in the end, blew up on my face and i rolled back to using queryString
instead.
you can access the working demo on (https://tmt.pw) and refer the entire codebase (with documented instructions) on my github repository.
the architecture is rather not that of a conventional url shortening and redirection service because my methodology does not throw a 301/302 permanent redirect status but instead, uses javascript's window.open
to have a new url loaded on the same browser window (using _top
), based on the slug.
midway through the development i get to know that github pages serves a 404 if it doesn't recognise the path or have a resource already allocated against it in the project repository and that's what led me to plug rafael pedicini's single page apps for github pages - i doubt i'd have been able to host my service on github (for free), had it not been for this ingenious technique to deploy single page apps.
access to the original resources can be found here -
- the entire folder on my google drive
- a spreadsheet that acts as the datasource
- finally, the script itself
i'm still working my way through a whole bunch of caveats and from my bucket list but I'm more than happy to have your contributions considered too.
major learning from all of this was that in order to use e.pathInfo
, we'd need to append the script url and in doing so, end up having apps script prompt user to login using their google accounts (not particularly to allow script permissions but just because - we don't know yet).
overall, it has been a humbling experience for having to publish a tool of my own 😊 - also available on product hunt.