Absolutize v0.0.8

Intro

Absolutize is essentially a replication of the URI.join or URI.merge methods, however, these strictly adhere to html standards, unfortunately the rest of the world doesn’t. The absolutize gem attempts to replicate url parsing that browsers use, ignoring the encoding issues etc.

Installation

Install absolutize as a gem

gem install absolutize

Usage

new(base_url, options)

Creates a new absolutize object based on a base_url

  • base_url – This is the base url for the absolutize method, it should either be the url of the current page or if a base tag is supplied it should be the href attribute of the base tag
  • options – Options are passed in as a hash,
    • :remove_anchors – removes any anchor tags (false)
    • :force_escaping – forces escaping of urls if it hasn’t been done already (true)
    • :output_debug – puts debug info while processing the url (false)

absolutizer = Absolutize.new(“http://www.vamosa.com/mainfolder/”, :remove_anchors => true)

url(rel_url)

Absolutizes the url that is passed in based on the options that have already been configured

  • rel_url – The url to absolutize, this is the url that is used on the page and should be absolutized in relation to the base url.

absolutizer.url(“subfolder/index.html”)

License

The MIT License

Copyright © 2010 Vamosa Limited

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.