Protect against TypeError

Only attempt to call req.headers.accept.include() if req.headers.accept exists.
This commit is contained in:
Darius Kazemi 2018-11-17 15:05:18 -08:00
parent 04801687d9
commit 5ad4516a70

View file

@ -15,7 +15,7 @@ router.get('/:name', function (req, res) {
if (result === undefined) {
return res.status(404).json(`No record found for ${name}.`);
}
else if (req.headers.accept.includes('application/activity+json') || req.headers.accept.includes('application/json') || req.headers.accept.includes('application/json+ld')) {
else if (req.headers.accept && (req.headers.accept.includes('application/activity+json') || req.headers.accept.includes('application/json') || req.headers.accept.includes('application/json+ld'))) {
res.json(JSON.parse(result.actor));
}
else {