Browse files

Update turbolinks.rb

  • Loading branch information...
1 parent 75b0d71 commit f8fe25831b372f3ea2c0a62fed35dc101b1ae0a4 @mala mala committed Mar 23, 2013
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/turbolinks.rb
View
6 lib/turbolinks.rb
@@ -29,16 +29,16 @@ def set_request_method_cookie
module XDomainBlocker
private
- def is_sameorigin(a, b)
+ def same_origin?(a, b)
a = URI.parse(a)
b = URI.parse(b)
- a.scheme + a.host + a.port.to_s == b.scheme + b.host + b.port.to_s
+ [a.scheme, a.host, a.port] == [b.scheme, b.host, b.port]
end
def abort_xdomain_redirect
to_uri = response.headers['Location'] || ""
current = request.headers['X-XHR-Referer'] || ""
- if (!to_uri.empty? && !current.empty? && !is_sameorigin(current, to_uri))
+ unless to_uri.blank? || current.blank? || same_origin?(current, to_uri)
self.status = 403
end
end

0 comments on commit f8fe258

Please sign in to comment.