Skip to content

Commit 4900a70

Browse files
committed
fix: verify exact Algolia match
1 parent fb8b8fd commit 4900a70

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

app/composables/npm/useAlgoliaSearch.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,12 @@ export function useAlgoliaSearch() {
369369
let packageExists: boolean | null = null
370370
if (packageQueryIndex >= 0) {
371371
const pkgResponse = results[packageQueryIndex] as SearchResponse<AlgoliaHit> | undefined
372-
const exactHit = pkgResponse?.hits[0]
373-
packageExists = exactHit ? exactHit.name === checks?.checkPackage : false
372+
const [exactHit] = pkgResponse?.hits ?? []
373+
const isExactHit = exactHit?.name === checks?.checkPackage
374374

375-
if (exactHit) {
375+
packageExists = isExactHit
376+
377+
if (exactHit && isExactHit) {
376378
searchResult.objects = [
377379
hitToSearchResult(exactHit),
378380
...searchResult.objects.filter(result => result.package.name !== exactHit.name),

0 commit comments

Comments
 (0)