mirror of
https://github.com/tcgdex/cards-database.git
synced 2025-04-23 11:22:10 +00:00
fix: JSON endpoints not working as intended (#175)
* fix: set fetching name not stricly checking Signed-off-by: Avior <github@avior.me> * fix: finding card by set not testing set name Signed-off-by: Avior <github@avior.me>
This commit is contained in:
parent
7f83a6f8eb
commit
b55cab7c6f
@ -82,7 +82,10 @@ export default class Card implements LocalCard {
|
|||||||
const res = (require(`../../../generated/${lang}/cards.json`) as Array<SDKCard>).find((c) => {
|
const res = (require(`../../../generated/${lang}/cards.json`) as Array<SDKCard>).find((c) => {
|
||||||
return objectLoop(params, (it, key) => {
|
return objectLoop(params, (it, key) => {
|
||||||
if (key === 'set' && typeof it === 'string') {
|
if (key === 'set' && typeof it === 'string') {
|
||||||
return c['set'].id.toLowerCase().includes(it.toLowerCase()) || c['set'].name.toLowerCase().includes(it.toLowerCase())
|
return (
|
||||||
|
c['set'].id.toLowerCase().includes(it.toLowerCase()) ||
|
||||||
|
c['set'].name?.toLowerCase()?.includes(it.toLowerCase())
|
||||||
|
)
|
||||||
}
|
}
|
||||||
if (typeof it === "string") {
|
if (typeof it === "string") {
|
||||||
return c[key as 'localId'].toLowerCase().includes(it.toLowerCase())
|
return c[key as 'localId'].toLowerCase().includes(it.toLowerCase())
|
||||||
|
@ -60,7 +60,9 @@ export default class Set implements LocalSet {
|
|||||||
public static findOne(lang: SupportedLanguages, params: Partial<Record<keyof Set, any>> = {}) {
|
public static findOne(lang: SupportedLanguages, params: Partial<Record<keyof Set, any>> = {}) {
|
||||||
const res = (require(`../../../generated/${lang}/sets.json`) as Array<SDKSet>).find((c) => {
|
const res = (require(`../../../generated/${lang}/sets.json`) as Array<SDKSet>).find((c) => {
|
||||||
return objectLoop(params, (it, key) => {
|
return objectLoop(params, (it, key) => {
|
||||||
if (typeof it === 'string') {
|
if (key === 'id' || key === 'name') {
|
||||||
|
return c[key as 'id'].toLowerCase() === it.toLowerCase()
|
||||||
|
} else if (typeof it === 'string') {
|
||||||
return c[key as 'id'].toLowerCase().includes(it.toLowerCase())
|
return c[key as 'id'].toLowerCase().includes(it.toLowerCase())
|
||||||
}
|
}
|
||||||
return c[key as 'id'].includes(it)
|
return c[key as 'id'].includes(it)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user