Skip to content
Draft
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: 3 additions & 0 deletions lib/controllers/page_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ def restrict_concealed(page)
end

get '/:slug' do
if params[:slug].include?(" ")
redirect "/#{params[:slug].tr(' ', '_')}", 301
end
@page = Page
.select(:id, :slug, :title, :concealed, :revision, :updated_on, :compiled_content, :author_id)
.eager_graph(:author)
Expand Down
7 changes: 7 additions & 0 deletions test/integration/app_not_logged_in_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ def test_nonexistent_page
assert_equal "/new/#{random_slug}", URI(redirect_location).path
end

def test_page_with_space_in_slug_redirects_to_underscore
get "/foo%20bar"

assert_equal 301, last_response.status
assert_equal "/foo_bar", URI(last_response["Location"]).path
end

def test_new
get "/new"

Expand Down
Loading