rule out html accepting requests from json path in case of very broad accept headers

This commit is contained in:
Will Murphy 2019-09-27 23:39:57 -05:00
parent ab44393c0b
commit b469abc863

View file

@ -14,7 +14,11 @@ function activity (req, res, next) {
} }
function jsonld (req, res, next) { function jsonld (req, res, next) {
if (req.method === 'GET' && req.accepts(pub.consts.jsonldTypes)) { if (
req.method === 'GET' && !req.accepts('html') &&
req.accepts(pub.consts.jsonldTypes)
) {
// rule out html because some browsers accept */* at end of list
return next() return next()
} }
if (req.method === 'POST' && req.is(pub.consts.jsonldTypes)) { if (req.method === 'POST' && req.is(pub.consts.jsonldTypes)) {