Abusing the GitHub URL Shortener

By Jacob Strieb

Published on November 23, 2020


Edit (January 11, 2022)

As of today, GitHub is no longer accepting new URLs at git.io. That means that this article is no longer relevant, and the code featured below probably won’t work. For more, read their blog post here:

https://github.blog/changelog/2022-01-11-git-io-no-longer-accepts-new-urls/


Since creating URL Pages, I have been looking for a URL shortener that does not limit the length of submitted links, since those generated by URL Pages can be obscenely long. Even the most generous shortening services I have discovered limit the URL size to between 2,000 and 5,000 bytes. Recently, however, a user on GitHub pointed out the existence of a GitHub-exclusive link shortener.1 Released in 2011,2 the service lives at git.io. Excitingly, some testing revealed that it does not seem to have a length limit on submitted URLs!

Despite being very useful for reducing the size of long URL Pages links, git.io is unusable for pages that are not on a GitHub domain. But by using URL Pages and JavaScript’s window.location.replace function, we can work around this!

The form below will fill the given URL into the following HTML template, generate a URL Pages link for it, and then retrieve the git.io shortened link. This will use JavaScript to redirect to the original URL entered by the user. We can now shorten URLs from any domain—of any length—using the GitHub link shortener!

<html>
<script>
window.location.replace("{{ INPUT URL }}")
</script>
</html>







  1. https://github.com/jstrieb/link-lock/issues/2↩︎

  2. https://github.blog/2011-11-10-git-io-github-url-shortener/↩︎