ExpandUrl
Expand urls shortened by URL shorteners, it supports all well-known shorteners. It balances the load randomly over multiple APIs.
gem 'expandurl'
Usage
url = ExpandUrl.new 'http://bit.ly/Wdz42Dz'
url.service # => bit.ly
url. # => http://google.com/
# Some APIs prefer that you specify the User Agent to identify your app
# Set it using #user_agent:
url = ExpandUrl.new 'http://bit.ly/RYlFh'
url.service # => bit.ly
url.user_agent = 'ApplicationName/1.0'
url. # => http://yehudakatz.com/
Behaviour
Like mentioned before, this gem uses multiple remote APIs that expand the given url. It chooses one randomly, and if the first one fails, it tries the second.
When a url is already a full url, both #service
and #expand
will return false.
When a url is unvalid, like htp:/abc
, both #service
and #expand
will return false.
URL shortener services supported
For a full list, check lib/services.yml