Added link checking

This commit is contained in:
benni 2018-02-09 13:23:38 +01:00
parent 288269be8f
commit 5f50c62a89

View file

@ -151,6 +151,9 @@ app.get('/debug/frame/', async (req, res) => {
app.get('/:templateName/', async (req, res) => { app.get('/:templateName/', async (req, res) => {
if (!templates[req.params.templateName]) return res.status(404).end(); if (!templates[req.params.templateName]) return res.status(404).end();
try { try {
if(!/^https?:/.test(req.query.url)) {
return res.status(400).end("Invalid url!")
}
const img = new ImageEx(req.query.url); const img = new ImageEx(req.query.url);
const canvas = render(templates[req.params.templateName], await img.loaded); const canvas = render(templates[req.params.templateName], await img.loaded);
return canvas.export(res); return canvas.export(res);