Skip to content
Open
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
8 changes: 4 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,12 @@
# Journal names routinely contain periods (e.g. "Cryptogamie. Algologie"),
# which Rails' default segment matcher excludes to leave room for format
# detection (":journal.json"), so it silently truncates them instead.
# Constrain :journal to swallow everything but a real trailing ".json"/
# ".html", so a literal period in the name is matched as part of :journal
# while an actual format suffix is still recognized.
# Journal names can also contain slashes. Constrain :journal to swallow
# everything but a real trailing ".json"/".html", so literal punctuation
# is matched as part of :journal while a format suffix is still recognized.
resources(
:journals, only: %i[index show], param: :journal,
constraints: { journal: /[^\/]+?/, format: /json|html/ }
constraints: { journal: /.+?/, format: /json|html/ }
)

# Publications
Expand Down
9 changes: 9 additions & 0 deletions test/controllers/journals_controller_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
require 'test_helper'

class JournalsControllerTest < ActionDispatch::IntegrationTest
test 'journal names with slashes generate links and resolve to the full name' do
journal = "Annales de l'Institut Pasteur / Microbiologie"

path = journal_path(journal)
get(path)
assert_response :success
assert_equal journal, @request.params[:journal]
end

test 'show resolves a journal name with an embedded period, untruncated' do
get('/journals/' + ERB::Util.url_encode('Cryptogamie. Algologie'))
assert_response :success
Expand Down
Loading