Class: LWR::Simple

Inherits:
Object
  • Object
show all
Defined in:
lib/goodies/lwr-simple.rb

Class Method Summary collapse

Class Method Details

.normalize(url) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/goodies/lwr-simple.rb', line 8

def self.normalize(url)
  case url
    when URI
    when String
      url = URI.parse(url)
    else
      raise ArgumentError, "URI or String expected, got: "
  end

  unless url.scheme
    url = URI.parse("http://" << url.to_s)
  end

  if url.path.empty?
    url.path = "/"
  end

  url
end