parent
0a500f16cd
commit
f6b2ae523d
|
@ -104,17 +104,18 @@ fastify.get('/:shortcode', async (req, res) => {
|
|||
if (!shortcode) {
|
||||
return 404;
|
||||
}
|
||||
const target = await knex.select('target')
|
||||
const target = await knex.select('target', 'no_preview')
|
||||
.from('urls')
|
||||
.where('shortcode', '=', shortcode)
|
||||
.limit(1);
|
||||
if (!target[0]) {
|
||||
return 404
|
||||
}
|
||||
if(isBot(req.headers['user-agent'])){
|
||||
|
||||
if(isBot(req.headers['user-agent']) && target[0].no_preview){
|
||||
return "Bad Bot!"
|
||||
}
|
||||
|
||||
|
||||
res.redirect(302, target[0].target);
|
||||
await knex('visits').insert({ shortcode, provider: 'native' });
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue