Skip to content

Instantly share code, notes, and snippets.

@rileylev
Created January 15, 2019 03:07
Show Gist options
  • Save rileylev/c26e2f4bb63816a45ddf60b1b8bba89f to your computer and use it in GitHub Desktop.
Save rileylev/c26e2f4bb63816a45ddf60b1b8bba89f to your computer and use it in GitHub Desktop.
tinyurl
var tinyurl = "http://tinyurl.com/"
var urls = []
var encode = function(longUrl){
urls.push(longUrl)
return tinyurl+(urls.length-1)
};
var decode = function(shortUrl){
var index = Number(shortUrl.substring(tinyurl.length))
return urls[index]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment