Skip to content

Commit

Permalink
Check untranslatable requested type for RDF
Browse files Browse the repository at this point in the history
  • Loading branch information
csarven committed Jan 30, 2024
1 parent 302ef62 commit 65b04bb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/handlers/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,18 @@ async function handler (req, res, next) {

// If it is not in our RDFs we can't even translate,
// Sorry, we can't help
if (!possibleRDFType) {
return next(error(406, 'Cannot serve requested type: ' + contentType))
if (!possibleRDFType || !RDFs.includes(requestedType)) {
return next(error(406, 'Cannot serve requested type: ' + requestedType))
}

try {
// Translate from the contentType found to the possibleRDFType desired
const data = await translate(stream, baseUri, contentType, possibleRDFType)
debug(req.originalUrl + ' translating ' + contentType + ' -> ' + possibleRDFType)
res.setHeader('Content-Type', possibleRDFType)
res.send(data)
return next()
} catch (err) {
}
catch (err) {
debug('error translating: ' + req.originalUrl + ' ' + contentType + ' -> ' + possibleRDFType + ' -- ' + 406 + ' ' + err.message)
return next(error(406, 'Cannot serve requested type: ' + requestedType))
}
Expand Down

0 comments on commit 65b04bb

Please sign in to comment.