Skip to content

Commit 2a10d20

Browse files
committed
fix: add defensive checks for invalid dates and case-insensitive keyword matching
1 parent fbaf2d9 commit 2a10d20

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

app/components/PackageTableRow.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ function formatDownloads(count?: number): string {
2727
function formatDate(dateStr?: string): string {
2828
if (!dateStr) return '-'
2929
const date = new Date(dateStr)
30+
if (Number.isNaN(date.getTime())) return '-'
3031
const now = new Date()
3132
const diffMs = now.getTime() - date.getTime()
3233
const diffSeconds = Math.floor(diffMs / 1000)

app/composables/useStructuredFilters.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ export function useStructuredFilters(options: UseStructuredFiltersOptions) {
226226

227227
function matchesKeywords(pkg: NpmSearchResult, keywords: string[]): boolean {
228228
if (keywords.length === 0) return true
229-
const pkgKeywords = pkg.package.keywords ?? []
230-
// AND logic: package must have ALL selected keywords
231-
return keywords.every(k => pkgKeywords.includes(k))
229+
const pkgKeywords = new Set((pkg.package.keywords ?? []).map(k => k.toLowerCase()))
230+
// AND logic: package must have ALL selected keywords (case-insensitive)
231+
return keywords.every(k => pkgKeywords.has(k.toLowerCase()))
232232
}
233233

234234
function matchesSecurity(pkg: NpmSearchResult, security: SecurityFilter): boolean {

0 commit comments

Comments
 (0)