Sha256: fb913db5cc693a45a4ae8b597b608da149a116e6f0af1ef389165d70d27ce829
Contents?: true
Size: 900 Bytes
Versions: 1
Compression:
Stored size: 900 Bytes
Contents
require 'activesupport' require 'open-uri' class String # Converts a relative url to a absolute url # Example: # '/foo.html'.to_absolute_url('http://www.google.com/index.html?foo=b') # => http://www.google.com/foo.html # '?foo=a'.to_absolute_url('http://www.google.com/index.html?foo=b') # => http://www.google.com/index.html?foo=a def to_absolute_url(origin_url) # :nodoc: begin #BUG in URI.join? URI.join('http://www.google.com/index.html?foo=b','?foo=a') # => http://www.google.com/?foo=a stripped = self.strip if stripped.starts_with?('?') origin_url.gsub(/\?.*/,'') + stripped else URI.join(origin_url,stripped).to_s end rescue self end end # Removes a fragment from a URL # Example: # '/foo.html#fsajfksafd'.remove_fragment # => /foo.html def remove_fragment self.gsub(/#.*/,'') end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
magellan-0.1.3 | lib/magellan/extensions/string.rb |