Class: UriHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/uri_helper.rb

Overview

Helper class to perform tasks on URI’s

Class Method Summary collapse

Class Method Details

.join_no_fragment(content, link) ⇒ Object

Returns an Addressable::URI with the fragment section removed



4
5
6
7
8
# File 'lib/uri_helper.rb', line 4

def self.join_no_fragment(content, link)
  new_link = Addressable::URI.join(content, link)
  new_link.fragment=nil
  new_link
end

.parse(url) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/uri_helper.rb', line 10

def self.parse(url)
  begin
    URI.parse(url)
  rescue URI::InvalidURIError
    URI.parse(URI.escape(url))
  end
end