Add trailing slash redirections

Fixes #13.
pull/15/head
Thibaut 11 years ago
parent 5ed7722448
commit dec2f5a249

@ -118,13 +118,20 @@ class App < Sinatra::Application
end
end
get %r{\A/(.+?)(?=\-|/)} do |doc|
get '/ping' do
200
end
get %r{\A/(\w+)(\-[\w\-]+)?(/)?(.+)?\z} do |doc, type, slash, rest|
return 404 unless @doc = settings.docs[doc]
if !rest && !slash
redirect "/#{doc}#{type}/"
elsif rest && rest.end_with?('/')
redirect "#{doc}#{type}#{slash}#{rest[0...-1]}"
else
erb :other
end
get '/ping' do
200
end
not_found do

Loading…
Cancel
Save