diff options
author | Michał Górny <mgorny@gentoo.org> | 2018-05-25 13:17:39 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2018-05-25 13:17:39 +0200 |
commit | 2c9b05a764abf323e972382acd2c0e6b366de1ca (patch) | |
tree | 26d0f5dcc851021da116f7d8dba59179d40f7243 | |
parent | Update the copyright years. (diff) | |
download | frontend-2c9b05a764abf323e972382acd2c0e6b366de1ca.tar.gz frontend-2c9b05a764abf323e972382acd2c0e6b366de1ca.tar.bz2 frontend-2c9b05a764abf323e972382acd2c0e6b366de1ca.zip |
Add redirects for missing/extraneous trailing slashes
It is horribly irritating and against the best practices to support URLs
with trailing slash and at the same time 404 on URLs without one. Add
redirects to fix that and makes using the archives less painful.
Bug: https://bugs.gentoo.org/656386
-rw-r--r-- | ag-web.rb | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -101,6 +101,14 @@ get '/:list/' do end end +get '/:list/threads/:year-:month' do + redirect '/%s/threads/%s-%s/' % [params[:list], params[:year], params[:month]] +end + +get '/:list/threads/:year-:month/:page/' do + redirect '/%s/threads/%s-%s/%s' % [params[:list], params[:year], params[:month], params[:page]] +end + get '/:list/threads/:year-:month/:page?' do return unless list_check @@ -128,6 +136,14 @@ get '/:list/threads/:year-:month/:page?' do end end +get '/:list/messages/:year-:month' do + redirect '/%s/messages/%s-%s/' % [params[:list], params[:year], params[:month]] +end + +get '/:list/messages/:year-:month/:page/' do + redirect '/%s/messages/%s-%s/%s' % [params[:list], params[:year], params[:month], params[:page]] +end + get '/:list/messages/:year-:month/:page?' do return unless list_check @@ -155,6 +171,10 @@ get '/:list/messages/:year-:month/:page?' do end end +get '/:list/message/:msgid/' do + redirect '/%s/message/%s' % [params[:list], params[:msgid]] +end + get '/:list/message/:msgid' do return unless list_check |