Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/mini_profiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ def call(env)
end
)
if skip_it
return client_settings.handle_cookie(@app.call(env))
# preserve_cookie to ensure we don't deauthorize the request (delete the auth cookie) when loading assets
return client_settings.handle_cookie(@app.call(env), preserve_cookie: true)
end

skip_it = (@config.pre_authorize_cb && !@config.pre_authorize_cb.call(env))
Expand Down
4 changes: 2 additions & 2 deletions lib/mini_profiler/client_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ def initialize(env, store, start)

end

def handle_cookie(result)
def handle_cookie(result, preserve_cookie: false)
status, headers, _body = result

if (MiniProfiler.config.authorization_mode == :allow_authorized && !MiniProfiler.request_authorized?)
# this is non-obvious, don't kill the profiling cookie on errors or short requests
# this ensures that stuff that never reaches the rails stack does not kill profiling
if status.to_i >= 200 && status.to_i < 300 && ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - @start) > 0.1)
if !preserve_cookie && status.to_i >= 200 && status.to_i < 300 && ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - @start) > 0.1)
discard_cookie!(headers)
end
else
Expand Down
4 changes: 3 additions & 1 deletion lib/mini_profiler_rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ def self.serves_static_assets?(app)
return false
end

if ::Rails.version >= "5.0.0"
if ::Rails.version >= "5.1.0"
::Rails.configuration.public_file_server.enabled || ::Rails.configuration.assets.unknown_asset_fallback
elsif ::Rails.version >= "5.0.0"
::Rails.configuration.public_file_server.enabled
elsif ::Rails.version >= "4.2.0"
::Rails.configuration.serve_static_files
Expand Down