Skip to content

Commit

Permalink
ignore non-parseable strings
Browse files Browse the repository at this point in the history
  • Loading branch information
theorm committed Apr 19, 2024
1 parent bcd64dd commit 543bf7a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
7 changes: 6 additions & 1 deletion src/hooks/parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ export const decodeJsonQueryParameters = (parametersNames: string[]) => async (c
for (const parameterName of parametersNames) {
if (query[parameterName] != null) {
if (typeof query[parameterName] === 'string') {
query[parameterName] = JSON.parse(query[parameterName] as string)
try {
query[parameterName] = JSON.parse(query[parameterName] as string)
} catch {
// Do nothing - it may be a protobuf filter
// if not - this will buble up as an error later
}
} else if (Array.isArray(query[parameterName])) {
const items = (query[parameterName] as string[]).map(item =>
typeof item === 'string' ? JSON.parse(item) : item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"properties": {
"passages": {
"type": "array",
"minimum": 0,
"items": {
"$ref": "#/definitions/passageItem"
}
Expand Down Expand Up @@ -36,13 +35,8 @@
"description": "IIIF Urls of article pages mentioned in the passage"
}
},
"required": [
"passage"
]
"required": ["passage"]
}
},
"required": [
"passages",
"info"
]
}
"required": ["passages", "info"]
}

0 comments on commit 543bf7a

Please sign in to comment.