Permalink
Browse files

Ensure entity uri has scheme

  • Loading branch information...
1 parent 931777a commit 183c7c5aa7d6c4268e6ef7dcf0507c30d997f60e Jesse Stuart committed Oct 4, 2012
Showing with 9 additions and 1 deletion.
  1. +9 −1 lib/omniauth/strategies/tent.rb
@@ -25,7 +25,7 @@ def request_params
def request_phase
if request.post? && request_params.entity
- set_state(:entity, request_params.entity)
+ set_state(:entity, ensure_entity_has_scheme(request_params.entity))
perform_discovery!
find_or_create_app!
build_uri_and_redirect!
@@ -54,6 +54,14 @@ def callback_phase
private
+ def ensure_entity_has_scheme(entity_uri)
+ if entity_uri =~ %r{^[a-z]{3,}?://}
+ entity_uri
+ else
+ "https://#{entity_uri}"
+ end
+ end
+
def set_state(key, val)
session["omniauth.#{key}"] = val
val

0 comments on commit 183c7c5

Please sign in to comment.