diff --git a/app/controllers/concerns/web_app_controller_concern.rb b/app/controllers/concerns/web_app_controller_concern.rb
index e1f599dcb0..ebbdba59af 100644
--- a/app/controllers/concerns/web_app_controller_concern.rb
+++ b/app/controllers/concerns/web_app_controller_concern.rb
@@ -31,7 +31,7 @@ module WebAppControllerConcern
def redirect_unauthenticated_to_permalinks!
return if user_signed_in? && current_account.moved_to_account_id.nil?
- permalink_redirector = PermalinkRedirector.new(request.path)
+ permalink_redirector = PermalinkRedirector.new(request.original_fullpath)
return if permalink_redirector.redirect_path.blank?
expires_in(15.seconds, public: true, stale_while_revalidate: 30.seconds, stale_if_error: 1.day) unless user_signed_in?
diff --git a/app/javascript/mastodon/features/ui/index.jsx b/app/javascript/mastodon/features/ui/index.jsx
index a6e3640478..2f9f962b81 100644
--- a/app/javascript/mastodon/features/ui/index.jsx
+++ b/app/javascript/mastodon/features/ui/index.jsx
@@ -186,7 +186,7 @@ class SwitchingColumnsArea extends PureComponent {
{redirect}
{singleColumn ? : null}
- {singleColumn && pathName.startsWith('/deck/') ? : null}
+ {singleColumn && pathName.startsWith('/deck/') ? : null}
{/* Redirect old bookmarks (without /deck) with home-like routes to the advanced interface */}
{!singleColumn && pathName === '/getting-started' ? : null}
{!singleColumn && pathName === '/home' ? : null}
diff --git a/app/lib/permalink_redirector.rb b/app/lib/permalink_redirector.rb
index f551f69db8..142a05d10d 100644
--- a/app/lib/permalink_redirector.rb
+++ b/app/lib/permalink_redirector.rb
@@ -83,6 +83,6 @@ class PermalinkRedirector
end
def path_segments
- @path_segments ||= @path.delete_prefix('/deck').delete_prefix('/').split('/')
+ @path_segments ||= @path.split('?')[0].delete_prefix('/deck').delete_prefix('/').split('/')
end
end
diff --git a/spec/lib/permalink_redirector_spec.rb b/spec/lib/permalink_redirector_spec.rb
index 3f77d7665a..5a544c3d38 100644
--- a/spec/lib/permalink_redirector_spec.rb
+++ b/spec/lib/permalink_redirector_spec.rb
@@ -29,5 +29,20 @@ RSpec.describe PermalinkRedirector do
redirector = described_class.new('@alice/123')
expect(redirector.redirect_path).to eq 'https://example.com/status-123'
end
+
+ it 'returns path for legacy status links with a query param' do
+ redirector = described_class.new('statuses/123?foo=bar')
+ expect(redirector.redirect_path).to eq 'https://example.com/status-123'
+ end
+
+ it 'returns path for pretty status links with a query param' do
+ redirector = described_class.new('@alice/123?foo=bar')
+ expect(redirector.redirect_path).to eq 'https://example.com/status-123'
+ end
+
+ it 'returns path for deck URLs with query params' do
+ redirector = described_class.new('/deck/directory?local=true')
+ expect(redirector.redirect_path).to eq '/directory?local=true'
+ end
end
end