DEV: Improve mini_profiler skipped paths (#20544)

- Remove no-longer-used `commits-widget` and `site_customizations` paths
- Add `/presence/`
- Move from regex to strings. The unanchored regexes were causing unexpected behaviour (e.g. if a topic had the word `assets` in its slug, it would be skipped). When passed strings, mini-profiler uses `String#starts_with?` for comparison
- Add `Discourse.base_path` to ensure proper functionality in subfolder environments
This commit is contained in:
David Taylor 2023-03-06 11:39:15 +00:00 committed by GitHub
parent 41f933ce89
commit 62dc37ac35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,33 +29,32 @@ if defined?(Rack::MiniProfiler) && defined?(Rack::MiniProfiler::Config)
GlobalSetting.mini_profiler_snapshots_transport_url GlobalSetting.mini_profiler_snapshots_transport_url
Rack::MiniProfiler.config.snapshots_transport_auth_key = Rack::MiniProfiler.config.snapshots_transport_auth_key =
GlobalSetting.mini_profiler_snapshots_transport_auth_key GlobalSetting.mini_profiler_snapshots_transport_auth_key
Rack::MiniProfiler.config.skip_paths = [ Rack::MiniProfiler.config.skip_paths =
%r{^/message-bus}, %w[
%r{^/extra-locales}, /assets/
%r{topics/timings}, /cdn_asset/
/assets/, /extra-locales/
%r{/user_avatar/}, /favicon/proxied
%r{/letter_avatar/}, /highlight-js/
%r{/letter_avatar_proxy/}, /images/
%r{/highlight-js/}, /javascripts/
%r{/svg-sprite/}, /letter_avatar_proxy/
/qunit/, /letter_avatar/
%r{srv/status}, /logs
/commits-widget/, /manifest.webmanifest
%r{^/cdn_asset}, /message-bus/
%r{^/logs}, /opensearch.xml
%r{^/site_customizations}, /presence/
%r{^/uploads}, /secure-media-uploads/
%r{^/secure-media-uploads}, /secure-uploads/
%r{^/secure-uploads}, /srv/status
%r{^/javascripts/}, /stylesheets/
%r{^/images/}, /svg-sprite/
%r{^/stylesheets/}, /theme-javascripts
%r{^/favicon/proxied}, /topics/timings
%r{^/theme-javascripts}, /uploads/
%r{^/manifest.webmanifest}, /user_avatar/
%r{^/opensearch.xml}, ].map { |path| "#{Discourse.base_path}#{path}" }
]
# we DO NOT WANT mini-profiler loading on anything but real desktops and laptops # we DO NOT WANT mini-profiler loading on anything but real desktops and laptops
# so let's rule out all handheld, tablet, and mobile devices # so let's rule out all handheld, tablet, and mobile devices