Skip to content

Commit 65b04bb

Browse files
committed
Check untranslatable requested type for RDF
1 parent 302ef62 commit 65b04bb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/handlers/get.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,18 @@ async function handler (req, res, next) {
116116

117117
// If it is not in our RDFs we can't even translate,
118118
// Sorry, we can't help
119-
if (!possibleRDFType) {
120-
return next(error(406, 'Cannot serve requested type: ' + contentType))
119+
if (!possibleRDFType || !RDFs.includes(requestedType)) {
120+
return next(error(406, 'Cannot serve requested type: ' + requestedType))
121121
}
122-
123122
try {
124123
// Translate from the contentType found to the possibleRDFType desired
125124
const data = await translate(stream, baseUri, contentType, possibleRDFType)
126125
debug(req.originalUrl + ' translating ' + contentType + ' -> ' + possibleRDFType)
127126
res.setHeader('Content-Type', possibleRDFType)
128127
res.send(data)
129128
return next()
130-
} catch (err) {
129+
}
130+
catch (err) {
131131
debug('error translating: ' + req.originalUrl + ' ' + contentType + ' -> ' + possibleRDFType + ' -- ' + 406 + ' ' + err.message)
132132
return next(error(406, 'Cannot serve requested type: ' + requestedType))
133133
}

0 commit comments

Comments
 (0)