Redirect routes with trailing slashes

See: https://github.com/hanami/router/issues/256
This commit is contained in:
2023-11-19 09:35:59 +11:00
parent f63df9b1ca
commit e48affacb8
3 changed files with 9 additions and 0 deletions

View File

@@ -30,6 +30,7 @@ gem "gnuplot"
gem "matrix"
gem "rack-session"
gem "rack-rewrite"
gem "ruby-readability", require: "readability"
gem "down"

View File

@@ -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)
@@ -517,6 +518,7 @@ DEPENDENCIES
pinboard!
puma
que
rack-rewrite
rack-session
rack-test
rake

View File

@@ -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