fix media proxying (clicking preview.redd.it image links was broken after 3612345fab

This commit is contained in:
teddit 2022-05-01 19:14:39 +02:00
parent e640e794db
commit 8ccc694d2f
1 changed files with 4 additions and 0 deletions

View File

@ -38,6 +38,10 @@ homeRoute.get('/:sort?', async (req, res, next) => {
} else {
let params = new URLSearchParams(req.query).toString();
media_url = `https://preview.redd.it/${sortby}?${params}`;
if (media_url.includes('teddit_proxy')) {
// if the URL includes teddit_proxy query param, remove everything after it
media_url = media_url.split('%3Fteddit_proxy')[0];
}
}
let proxied_media = await downloadAndSave(media_url);