Permalink
Browse files

Do not store redirect_to location in session if the request did not c…

…ome from Turbolinks - Closes #317
  • Loading branch information...
reed committed Jan 23, 2014
1 parent 18b5965 commit 7baa5e93be600c9553cd9c5644d19d03253dd7c7
Showing with 17 additions and 1 deletion.
  1. +10 −0 CHANGELOG.md
  2. +7 −1 lib/turbolinks.rb
View
@@ -1,3 +1,13 @@
+## Turbolinks (master)
+
+* Do not store redirect_to location in session if the request did not come from Turbolinks. Fixes
+ rare bug that manifests when directing items like image tag sources through ActionController and
+ subsequently redirecting those requests to a different origin. This would cause the session variable
+ to be set but never deleted (since the redirect request was external), resulting in the next request
+ being declared a redirect no matter what.
+
+ *Nick Reed*
+
## Turbolinks 2.2.0 (January 10, 2014)
* Add transition cache feature. When enabled, cached copies of pages will be shown
View
@@ -8,12 +8,18 @@ module XHRHeaders
private
def _compute_redirect_to_location_with_xhr_referer(options)
- session[:_turbolinks_redirect_to] =
+ store_for_turbolinks begin
if options == :back && request.headers["X-XHR-Referer"]
_compute_redirect_to_location_without_xhr_referer(request.headers["X-XHR-Referer"])
else
_compute_redirect_to_location_without_xhr_referer(options)
end
+ end
+ end
+
+ def store_for_turbolinks(url)
+ session[:_turbolinks_redirect_to] = url if request.headers["X-XHR-Referer"]
+ url
end
def set_xhr_redirected_to

0 comments on commit 7baa5e9

Please sign in to comment.