Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8929

Show
Ignore:
Timestamp:
02/25/08 21:04:02 (6 months ago)
Author:
bitsweat
Message:

strip whitespace from url before normalizing

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/open_id_authentication/lib/open_id_authentication.rb

    r8476 r8929  
    5858 
    5959  def self.normalize_url(url) 
    60     begin 
    61       uri = URI.parse(url) 
    62       uri = URI.parse("http://#{uri}") unless uri.scheme 
    63       uri.scheme = uri.scheme.downcase  # URI should do this 
    64       uri.normalize.to_s 
    65     rescue URI::InvalidURIError 
    66       raise InvalidOpenId.new("#{url} is not an OpenID URL") 
    67     end 
     60    uri = URI.parse(url.strip) 
     61    uri = URI.parse("http://#{uri}") unless uri.scheme 
     62    uri.scheme = uri.scheme.downcase  # URI should do this 
     63    uri.normalize.to_s 
     64  rescue URI::InvalidURIError 
     65    raise InvalidOpenId.new("#{url} is not an OpenID URL") 
    6866  end 
    6967 
  • plugins/open_id_authentication/test/normalize_test.rb

    r7214 r8929  
    2121    "http://loudthinking.com:8080"          => "http://loudthinking.com:8080/", 
    2222    "techno-weenie.net"                     => "http://techno-weenie.net/", 
    23     "http://techno-weenie.net"              => "http://techno-weenie.net/" 
     23    "http://techno-weenie.net"              => "http://techno-weenie.net/", 
     24    "http://techno-weenie.net  "            => "http://techno-weenie.net/" 
    2425  } 
    2526