1
0
mirror of https://github.com/tcgdex/cards-database.git synced 2025-06-14 00:29:19 +00:00

fix: sets not working when fetching with name

This commit is contained in:
2024-09-26 00:31:10 +02:00
parent 0a62d37f4e
commit 6e2c3f467b
5 changed files with 44 additions and 8 deletions

View File

@ -251,6 +251,7 @@ server
*/
.get('/:lang/:endpoint/:id/:subid', (req: CustomRequest, res) => {
let { id, lang, endpoint, subid } = req.params
console.log(req.params)
if (subid.endsWith('.json')) {
subid = subid.replace('.json', '')
@ -270,7 +271,7 @@ server
// allow the dev to use a non prefixed value like `10` instead of `010` for newer sets
result = Card
// @ts-expect-error normal behavior until the filtering is more fiable
.findOne(lang, { localId: { $or: [subid.padStart(3, '0'), subid]}, 'set.id': id })?.full()
.findOne(lang, { localId: { $or: [subid.padStart(3, '0'), subid]}, $or: [{ 'set.id': id }, { 'set.name': id }] })?.full()
break
}
if (!result) {

View File

@ -384,6 +384,9 @@ function filterItem(value: any, query: QueryValues<AllowedValues>): boolean {
* strict value check by default
*/
if (!(typeof query === 'object')) {
if (typeof query === 'string' && typeof value === 'string') {
return query.toLowerCase() === value.toLowerCase()
}
return query === value
}