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:
@ -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) {
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user