Clean-up some stuff
This commit is contained in:
parent
421e1f2169
commit
5e8bf0bf16
|
@ -12,7 +12,7 @@ sub by_id($self) {
|
||||||
unless keys %{$remark};
|
unless keys %{$remark};
|
||||||
|
|
||||||
# Set filename for right-click & save-as behavior
|
# Set filename for right-click & save-as behavior
|
||||||
if ($self->stash('format') eq 'txt') {
|
if ($self->accepts(0, 'txt')) {
|
||||||
$self->res->headers->content_disposition(
|
$self->res->headers->content_disposition(
|
||||||
"inline; filename=remark_${remark_id}.txt"
|
"inline; filename=remark_${remark_id}.txt"
|
||||||
)
|
)
|
||||||
|
|
|
@ -76,7 +76,7 @@ sub by_id($self) {
|
||||||
unless scalar @{$remarks} || $this_page == $last_page;
|
unless scalar @{$remarks} || $this_page == $last_page;
|
||||||
|
|
||||||
# Set filename for right-click & save-as behavior
|
# Set filename for right-click & save-as behavior
|
||||||
if ($self->stash('format') eq 'txt') {
|
if ($self->accepts(0, 'txt')) {
|
||||||
$self->res->headers->content_disposition(
|
$self->res->headers->content_disposition(
|
||||||
"inline; filename=thread_${thread_id}.txt"
|
"inline; filename=thread_${thread_id}.txt"
|
||||||
)
|
)
|
||||||
|
|
17
t/filename.t
Normal file
17
t/filename.t
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
use Mojo::Base -strict;
|
||||||
|
use Test::More;
|
||||||
|
use Test::Mojo;
|
||||||
|
|
||||||
|
my $t = Test::Mojo->new('PostText');
|
||||||
|
|
||||||
|
$t->get_ok('/thread/single/1.txt')->status_is(200)
|
||||||
|
->header_like('Content-Disposition' => qr/filename=thread_1\.txt/);
|
||||||
|
$t->get_ok('/thread/single/1')->status_is(200)
|
||||||
|
->header_unlike('Content-Disposition' => qr/filename=thread_1\.txt/);
|
||||||
|
|
||||||
|
$t->get_ok('/remark/single/1.txt')->status_is(200)
|
||||||
|
->header_like('Content-Disposition' => qr/filename=remark_1\.txt/);
|
||||||
|
$t->get_ok('/remark/single/1')->status_is(200)
|
||||||
|
->header_unlike('Content-Disposition' => qr/filename=remark_1\.txt/);
|
||||||
|
|
||||||
|
done_testing;
|
Loading…
Reference in New Issue
Block a user