Skip to content

Commit

Permalink
Merge pull request #2048 from tf/entry-redirect-other-host
Browse files Browse the repository at this point in the history
Allow other host in entry redirect
  • Loading branch information
tf authored Jan 5, 2024
2 parents 4f45da1 + 8b73c19 commit 59ed3a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/pageflow/entries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def entry_request_scope
def redirect_according_to_entry_redirect(entry)
return unless (redirect_location = entry_redirect(entry))

redirect_to(redirect_location, status: :moved_permanently)
redirect_to(redirect_location, status: :moved_permanently, allow_other_host: true)
end

def entry_redirect(entry)
Expand Down
11 changes: 11 additions & 0 deletions spec/requests/pageflow/entries_show_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,17 @@ module Pageflow
expect(response).to redirect_to('http://www.example.com/some-entry')
end

it 'allows redirecting to other host' do
entry = create(:entry, :published,
type_name: 'test')

Pageflow.config.public_entry_redirect = ->(_, _) { 'http://www.example.com/' }

get(short_entry_url(entry), headers: {'HTTP_HOST' => 'pageflow.example.com'})

expect(response).to redirect_to('http://www.example.com/')
end

it 'does not redirect if nil is returned' do
entry = create(:entry, :published,
type_name: 'test')
Expand Down

0 comments on commit 59ed3a8

Please sign in to comment.