Skip to content

Commit

Permalink
Redirect routes with trailing slashes
Browse files Browse the repository at this point in the history
  • Loading branch information
dNitza committed Nov 18, 2023
1 parent f63df9b commit e48affa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ gem "gnuplot"
gem "matrix"

gem "rack-session"
gem "rack-rewrite"

gem "ruby-readability", require: "readability"
gem "down"
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ GEM
que (2.3.0)
racc (1.7.3)
rack (2.2.8)
rack-rewrite (1.5.1)
rack-session (1.0.1)
rack (< 3)
rack-test (2.1.0)
Expand Down Expand Up @@ -517,6 +518,7 @@ DEPENDENCIES
pinboard!
puma
que
rack-rewrite
rack-session
rack-test
rake
Expand Down
6 changes: 6 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@ use Rack::Session::Cookie,
:expire_after => 3600*24,
:secret => ENV["SESSION_SECRET"]

require "rack/rewrite"
use Rack::Rewrite do
# remove trailing slashes
r302 %r{(/.*)/(\?.*)?$}, "$1$2"
end

run Hanami.app

0 comments on commit e48affa

Please sign in to comment.