fix: correct sitemap test count and steamdb version extraction

This commit is contained in:
2026-05-20 02:27:56 +08:00
parent 8da0dce723
commit c808747b9d
2 changed files with 10 additions and 3 deletions
+2 -3
View File
@@ -66,7 +66,6 @@ describe("Sitemap Generator (app/sitemap.ts)", () => {
vi.clearAllMocks() vi.clearAllMocks()
mockGameRows = [] mockGameRows = []
mockDeviceRows = [] mockDeviceRows = []
gamesCallCount = 0
devicesCallCount = 0 devicesCallCount = 0
}) })
@@ -80,8 +79,8 @@ describe("Sitemap Generator (app/sitemap.ts)", () => {
const result = await mod.default() const result = await mod.default()
expect(Array.isArray(result)).toBe(true) expect(Array.isArray(result)).toBe(true)
// At minimum: 6 static pages (games and devices are empty) // At minimum: 5 static pages (games and devices are empty)
expect(result.length).toBeGreaterThanOrEqual(6) expect(result.length).toBeGreaterThanOrEqual(5)
// First entry should be the homepage with priority 1 // First entry should be the homepage with priority 1
expect(result[0].url).toContain("deckyvault.xyz") expect(result[0].url).toContain("deckyvault.xyz")
expect(result[0].priority).toBe(1) expect(result[0].priority).toBe(1)
+8
View File
@@ -323,6 +323,14 @@ function extractVersionFromTable(html: string): string | null {
} }
} }
// Inline element pattern: "Last known name" followed by a <span> or other
// inline tag inside the same cell (e.g. <td>Last known name <span>v1.2.3</span></td>)
const inlineMatch = html.match(/Last known name[^<]*<[^>]*>([^<]+)</i)
if (inlineMatch) {
const val = inlineMatch[1].trim()
if (val.length > 1 && !val.startsWith("http")) return val
}
// Broader: look for "Last known name" anywhere nearby a <td> with content // Broader: look for "Last known name" anywhere nearby a <td> with content
const looseMatch = html.match(/Last known name[^<]*(?:<[^>]+>)*?\s*<t[hd][^>]*>([^<]+)</i) const looseMatch = html.match(/Last known name[^<]*(?:<[^>]+>)*?\s*<t[hd][^>]*>([^<]+)</i)
if (looseMatch) { if (looseMatch) {