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

Changeset 6334

Show
Ignore:
Timestamp:
03/05/07 03:05:41 (2 years ago)
Author:
david
Message:

Made normalize_url available to users outside of controllers with the module mixed in

Files:

Legend:

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

    r6331 r6334  
    4040  end 
    4141 
     42  def self.normalize_url(url) 
     43    url = url.downcase 
     44   
     45    case url 
     46    when %r{^https?://[^/]+/[^/]*} 
     47      url # already normalized 
     48    when %r{^https?://[^/]+$} 
     49      url + "/" 
     50    when %r{^[.\d\w]+/.*$} 
     51      "http://" + url 
     52    when %r{^[.\d\w]+$} 
     53      "http://" + url + "/" 
     54    else 
     55      raise "Unable to normalize: #{url}" 
     56    end 
     57  end 
     58 
    4259 
    4360  protected 
    4461    def normalize_url(url) 
    45       url = url.downcase 
    46      
    47       case url 
    48       when %r{^https?://[^/]+/[^/]*} 
    49         url # already normalized 
    50       when %r{^https?://[^/]+$} 
    51         url + "/" 
    52       when %r{^[.\d\w]+/.*$} 
    53         "http://" + url 
    54       when %r{^[.\d\w]+$} 
    55         "http://" + url + "/" 
    56       else 
    57         raise "Unable to normalize: #{url}" 
    58       end 
     62      OpenIdAuthentication.normalize_url(url) 
    5963    end 
    6064 
     
    114118    def open_id_redirect_url(open_id_response) 
    115119      open_id_response.redirect_url( 
    116         request.protocol + request.host
     120        request.protocol + request.host_with_port + "/"
    117121        open_id_response.return_to("#{request.url}?open_id_complete=1") 
    118122      )