Redirect for old /thread/post path

This commit is contained in:
swaggboi 2024-08-14 16:30:55 -04:00
parent 18634bbf60
commit decbc120e3
3 changed files with 15 additions and 1 deletions

View file

@ -61,7 +61,6 @@ tests locally:
## TODOs ## TODOs
- Redirect for `/thread/post`
- Implement [CSRF](https://docs.mojolicious.org/Mojolicious/Guides/Rendering#Cross-site-request-forgery) - Implement [CSRF](https://docs.mojolicious.org/Mojolicious/Guides/Rendering#Cross-site-request-forgery)
- Tripcodes/PGP signing somehow perhaps... - Tripcodes/PGP signing somehow perhaps...

View file

@ -182,6 +182,11 @@ sub startup($self) {
->to('thread#flag') ->to('thread#flag')
->name('flag_thread'); ->name('flag_thread');
# Redirect for this old path to the new one
$thread->any([qw{GET POST}], '/post', sub ($c) {
$c->redirect_to('post_thread')
});
$human_thread->any([qw{GET POST}], '/post') $human_thread->any([qw{GET POST}], '/post')
->to('thread#create') ->to('thread#create')
->name('post_thread'); ->name('post_thread');

10
t/redirect_old_path.t Normal file
View file

@ -0,0 +1,10 @@
use Mojo::Base -strict;
use Test::More;
use Test::Mojo;
my $t = Test::Mojo->new('PostText');
$t->get_ok('/thread/post')->status_is(302)
->header_like(Location => qr{human/thread/post});
done_testing;