A simple library that can unshorten any short url
A simple library that can unshorten any short url.
npm install unshortener
git clone https://github.com/Swizec/node-unshortener.git cd node-unshortener npm link
// expand an URLvar unshortener = require'unshortener';// you can pass in a url object or stringunshortenerexpand''// url is a url objectconsole.logurl;;
If you have a handy bitly account you should also pass in an options object to enable the unshortener to use the bitly API directly:
// expand an URLvar unshortener = require'unshortener';// you can pass in a url object or stringunshortenerexpand''bitly: username: '<YOUR BITLY USERNAME>'apikey: '<YOUR BITLY API KEY>'// url is a url objectconsole.logurl;;
When an error occurs the callback is passed the original url and an error flag.
node-unshortener aims to be able to unshorten any link possible, so it tries to behave as a browser and simply follows all the redirects. However, to be nice, when at all possible, it tries to use the url shortener's official API.
That said, please feel free to suggest any unshortening services I may have missed.
Services/domains directly supported so far:
Copyright (C) Swizec Teller email@example.com
Licensed under the GPL version 3 or later for non-commercial use.