0.01
No commit activity in last 3 years
No release in over 3 years
Simple gem to follow redirects to resolve the destination of a URL. Caches results sometimes.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

= 2.14.7

Runtime

 Project Readme

url_resolver

url_resolver follows redirects to resolve URLs. It's pretty alright.

Installation

Gemfile:

gem 'url_resolver'

Rubygems:

gem install url_resolver

Usage

UrlResolver.resolve('http://www.google.com')
# => "http://www.google.com"

UrlResolver.resolve('http://analytics.google.com')
# => "http://www.google.com/analytics/"

Configuration

url_resolver supports caching in case you're planning on hitting a lot of the same URLs over and over and over and over again.

It also supports using a custom list of errors to ignore.

UrlResolver.configure do |config|
  config.cache = Redis.new # default: nil
  config.cache_failures = true # default: true
  config.user_agent = 'Custom User-Agent' # default: 'Ruby'
  config.errors_to_ignore << MyModule::MyError
end

or

UrlResolver.configuration.cache = Redis.new
UrlResolver.configuration.cache_failures = true
UrlResolver.configuration.user_agent = 'Custom User-Agent'
UrlResolver.configuration.errors_to_ignore << MyModule::MyError

Changelog

0.1.1
  • Handle redirects that resolve to nonstandard protocols
0.1.0
  • Initial release

Todo

  • configurable cache timeouts + keys
  • non-Redis caches
  • more configurable failure handling (request timeouts, bad URLs, etc)
  • support non-RestClient http clients
  • relax and enjoy life