Skip to content

Commit

Permalink
Fix issue in vocabulariesSearch when non-existent URI is given
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandesu committed Oct 15, 2024
1 parent 9e07c1e commit c2d68dc
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,26 +114,20 @@ async function vocabulariesSearch (req, res, next) {
? backend.vocSearch({ properties: "*", search: query.search })
: backend.getSchemes({ properties: "*", params: query })

if (query.uri) {
search = search.then(result => {
if (result.length) {
return result[0]
} else {
next()
try {
const result = await search
if (query.uri) {
if (!result.length) {
return next()
}
})
.then(enrichItem)
.then(item => sendItem(req, res, item))
} else {
search =
search.then(result => {
const item = await enrichItem(result[0])
sendItem(req, res, item)
} else {
render(req, res, "vocabularies", { title: "Vocabularies", result, api: "voc" })
})
}
} catch (error) {
next(error)
}

search.catch(e => {
next(e)
})
}

async function enrichItem (item) {
Expand Down

0 comments on commit c2d68dc

Please sign in to comment.