Skip to content

Commit

Permalink
Merge pull request #1357 from sneakers-the-rat/bugfix-names-with-periods
Browse files Browse the repository at this point in the history
fix authors with periods in names
  • Loading branch information
arfon authored Aug 26, 2024
2 parents 4cd24da + 7bbe581 commit 9cd9623
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
get '/editors/lookup/:login', to: "editors#lookup"
get '/papers/lookup/:id', to: "papers#lookup"
get '/papers/in/:language', to: "papers#filter", as: 'papers_by_language'
get '/papers/by/:author', to: "papers#filter", as: 'papers_by_author'
get '/papers/by/:author', to: "papers#filter", as: 'papers_by_author', constraints: { author: /.*(?<!\.html)(?<!\.json)(?<!\.atom)/ }
get '/papers/edited_by/:editor', to: "papers#filter", as: 'papers_by_editor'
get '/papers/reviewed_by/:reviewer', to: "papers#filter", as: 'papers_by_reviewer'
get '/papers/tagged/:tag', to: "papers#filter", as: 'papers_by_tag'
Expand Down
35 changes: 35 additions & 0 deletions spec/controllers/papers_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -430,4 +430,39 @@
expect(response.media_type).to eq("application/atom+xml")
end
end

describe "Paper/by/{author} route" do
it "handles author names with periods" do
{
:get => "/papers/by/Author%20T.%20Lastname"
}.should route_to(
controller: "papers",
action: "filter",
author: "Author T. Lastname"
)
end

%w[json atom html].each do |format|
it "still allows #{format} suffix to be interpreted as format" do
{
:get => "/papers/by/Author%20T.%20Lastname.#{format}"
}.should route_to(
controller: "papers",
action: "filter",
author: "Author T. Lastname",
format: format
)
end

it "doesn't choke on #{format} in the middle of a name" do
{
:get => "/papers/by/Author.#{format}name%20T.%20Lastname"
}.should route_to(
controller: "papers",
action: "filter",
author: "Author.#{format}name T. Lastname",
)
end
end
end
end

0 comments on commit 9cd9623

Please sign in to comment.