Compare commits
No commits in common. "0fa043f0dfbae8b4095375b39c220a901cc6051f" and "d957ca52ea2332f6cd1c5608467be6245f5082b8" have entirely different histories.
0fa043f0df
...
d957ca52ea
@ -96,12 +96,6 @@ fastify.get('/e/:id', async (req, res) => {
|
||||
await knex('visits').insert({ shortcode: req.params.id, provider: 'e' });
|
||||
})
|
||||
|
||||
//Automagic reddit redirects on /r/
|
||||
fastify.get('/r/:id', async (req, res) => {
|
||||
res.redirect(302, `https://redd.it/${req.params.id}`)
|
||||
await knex('visits').insert({ shortcode: req.params.id, provider: 'r' });
|
||||
})
|
||||
|
||||
//Normal shorturls
|
||||
fastify.get('/:shortcode', async (req, res) => {
|
||||
const shortcode = req.params.shortcode;
|
||||
@ -443,16 +437,6 @@ function checkKnownProviders(target) {
|
||||
target
|
||||
}
|
||||
}
|
||||
|
||||
const redditID = target.match(/(((((?:https?:)?\/\/)((?!about\.)[\w-]+?\.)?([rc]edd(?:it\.com|\.it)))(?!\/(?:blog|about|code|advertising|jobs|rules|wiki|contact|buttons|gold|page|help|prefs|user|message|widget)\b)((?:\/r\/[\w-]+\b(?<!\/pcmasterrace))|(?:\/tb))?(\/comments)??(\/\w{2,7}\b(?<!\/46ijrl)(?<!\/wiki))((?:(?!\))\S)*)))/);
|
||||
if (redditID[9]) {
|
||||
const shortcode = `r${redditID[9]}`
|
||||
return {
|
||||
url: `${config.getBaseUrl()}/${shortcode}`,
|
||||
shortcode,
|
||||
target
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user