Commit 812d8e89 authored by Luc Didry's avatar Luc Didry

Now return 404 status for non-existent URLs

This commit is dedicated to Schoumi, who is supporting me on Tipeee. Many thanks :-)
parent b3f865fb
......@@ -19,7 +19,6 @@ sqlite1:
- MOJO_CONFIG=t/sqlite1.conf make test
tags:
- Debian
- Jessie
sqlite2:
stage: sqlite
cache:
......@@ -31,7 +30,6 @@ sqlite2:
- MOJO_CONFIG=t/sqlite2.conf make test
tags:
- Debian
- Jessie
sqlite3:
stage: sqlite
cache:
......@@ -41,11 +39,10 @@ sqlite3:
- local
script:
- MOJO_CONFIG=t/sqlite3.conf make minion &
- sleep 3
- sleep 5
- MOJO_CONFIG=t/sqlite3.conf make test
tags:
- Debian
- Jessie
postgresql1:
stage: postgresql
cache:
......@@ -60,7 +57,6 @@ postgresql1:
- MOJO_CONFIG=t/postgresql1.conf make test
tags:
- Debian
- Jessie
postgresql2:
stage: postgresql
cache:
......@@ -75,7 +71,6 @@ postgresql2:
- MOJO_CONFIG=t/postgresql2.conf make test
tags:
- Debian
- Jessie
postgresql3:
stage: postgresql
cache:
......@@ -89,11 +84,10 @@ postgresql3:
- service postgresql status
- su -c "psql -f t/test.sql" postgres
- MOJO_CONFIG=t/postgresql3.conf make minion &
- sleep 3
- sleep 5
- MOJO_CONFIG=t/postgresql3.conf make test
tags:
- Debian
- Jessie
mysql1:
stage: mysql
cache:
......@@ -109,7 +103,6 @@ mysql1:
- MOJO_CONFIG=t/mysql1.conf make test
tags:
- Debian
- Jessie
mysql2:
stage: mysql
cache:
......@@ -125,7 +118,6 @@ mysql2:
- MOJO_CONFIG=t/mysql2.conf make test
tags:
- Debian
- Jessie
mysql3:
stage: mysql
cache:
......@@ -139,8 +131,7 @@ mysql3:
- service mysql status
- mysql -u root < t/test_mysql.sql
- MOJO_CONFIG=t/mysql3.conf make minion &
- sleep 3
- sleep 5
- MOJO_CONFIG=t/mysql3.conf make test
tags:
- Debian
- Jessie
......@@ -6,6 +6,7 @@ Revision history for Perl application Lstu
- Option to blacklist and/or whitelist domains (#30)
- Option to set the maximum number of redirections (#31)
- Instance statistics available at /fullstats URL
- Now return 404 status for non-existent URLs
0.08 Wed Feb 08 18:49:00 2017 +0100
- Add Piwik tracking option
......
......@@ -307,13 +307,16 @@ sub get {
});
} else {
my $msg = $c->l('The shortened URL %1 doesn\'t exist.', $c->url_for('/')->to_abs.$short);
$c->res->code(404);
$c->respond_to(
json => { json => { success => Mojo::JSON->false, msg => $msg } },
any => sub {
my $c = shift;
$c->flash('msg' => $msg);
$c->redirect_to('index');
$c->render(
template => 'index',
msg => $msg
);
}
);
}
......
......@@ -74,7 +74,7 @@ $t->get_ok($a.'.json')
->json_is({success => true, url => 'https://lstu.fr'});
$t->get_ok($a.'i.json')
->status_is(200)
->status_is(404)
->json_is({success => false, msg => 'The shortened URL '.$a.'i doesn\'t exist.'});
# Test full stats
......@@ -110,7 +110,7 @@ $t->get_ok('/d/'.$b)
->status_is(200);
$t->get_ok($a.'i.json')
->status_is(200)
->status_is(404)
->json_is({success => false, msg => 'The shortened URL '.$a.'i doesn\'t exist.'});
$a = $t->ua->post('/a' => form => { lsturl => 'https://lstu.fr', format => 'json' })->res->json('/short');
......
......@@ -64,5 +64,8 @@
% end
% }
% if (defined(flash('msg'))) {
<h3 class="alert alert-danger"><%= flash('msg') %><h3>
<h3 class="alert alert-danger"><%= flash('msg') %></h3>
% }
% if (defined(stash('msg'))) {
<h3 class="alert alert-danger"><%= stash('msg') %></h3>
% }
......@@ -60,5 +60,8 @@
% end
% }
% if (defined(flash('msg'))) {
<h3 class="alert alert-danger"><%= flash('msg') %><h3>
<h3 class="alert alert-danger"><%= flash('msg') %></h3>
% }
% if (defined(stash('msg'))) {
<h3 class="alert alert-danger"><%= stash('msg') %></h3>
% }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment