FIX: Return a 404 when a sitemap request doesn't have a format (#16506)

This commit is contained in:
Roman Rizzi 2022-04-19 11:07:25 -03:00 committed by GitHub
parent 90f4e0230e
commit 48417b59d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -26,7 +26,7 @@ Discourse::Application.routes.draw do
post "webhooks/sendgrid" => "webhooks#sendgrid"
post "webhooks/sparkpost" => "webhooks#sparkpost"
scope path: nil, constraints: { format: :xml } do
scope path: nil, format: true, constraints: { format: :xml } do
resources :sitemap, only: [:index]
get "/sitemap_:page" => "sitemap#page", page: /[1-9][0-9]*/
get "/sitemap_recent" => "sitemap#recent"

View File

@ -12,6 +12,12 @@ describe SitemapController do
expect(response.status).to eq(404)
end
it "returns a 404 if the request does't have a format" do
get '/news'
expect(response.status).to eq(404)
end
end
describe '#index' do