Sha256: 799e31af12d5bd2564b4ddc7fd0f7178d4f635ea0dce74acb27a5cb4cbca94dd

Contents?: true

Size: 701 Bytes

Versions: 1

Compression:

Stored size: 701 Bytes

Contents

module Turbolinks
  # Corrects the behavior of url_for (and link_to, which uses url_for) with the :back
  # option by using the X-XHR-Referer request header instead of the standard Referer
  # request header.
  module LegacyXHRUrlFor
    def self.included(base)
      base.alias_method_chain :url_for, :xhr_referer
    end

    def url_for_with_xhr_referer(options = {})
      options = (controller.request.headers["X-XHR-Referer"] || options) if options == :back
      url_for_without_xhr_referer options
    end
  end

  module XHRUrlFor
    def url_for(options = {})
      options = (controller.request.headers["X-XHR-Referer"] || options) if options == :back
      super options
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
turbolinks-2.5.4 lib/turbolinks/xhr_url_for.rb