fix(live): tighten beIN Sports search matching (#27)
Require numeric query tokens to match numeric channel tokens exactly while preserving singular/plural and compact-name tolerance. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -6,7 +6,10 @@
|
||||
function normalizeSearch(value) {
|
||||
return String(value || '')
|
||||
.normalize('NFKD').replace(/[\u0300-\u036f]/g, '')
|
||||
.toLowerCase().replace(/[^a-z0-9]+/g, ' ').trim()
|
||||
.toLowerCase()
|
||||
.replace(/([a-z])([0-9])/g, '$1 $2')
|
||||
.replace(/([0-9])([a-z])/g, '$1 $2')
|
||||
.replace(/[^a-z0-9]+/g, ' ').trim()
|
||||
.split(/\s+/).filter(Boolean)
|
||||
.map(token => token.length > 3 && token.endsWith('s') ? token.slice(0, -1) : token);
|
||||
}
|
||||
@ -20,7 +23,10 @@
|
||||
variant.name, variant.tvgId, variant.categoryName, variant.groupTitle
|
||||
])
|
||||
].filter(Boolean).join(' '));
|
||||
return wanted.every(token => corpus.some(candidate => candidate.includes(token)));
|
||||
return wanted.every(token => corpus.some(candidate => {
|
||||
if (/^\d+$/.test(token)) return /^\d+$/.test(candidate) && Number(candidate) === Number(token);
|
||||
return candidate.includes(token);
|
||||
}));
|
||||
}
|
||||
|
||||
function normalizeLanguage(language) {
|
||||
|
||||
Reference in New Issue
Block a user