From 17d3be8892f91676dcea3b004a668441eaf3b77e Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 10 Sep 2026 01:36:49 +0200 Subject: [PATCH] Match a screenshot to its case the way PocketBase actually stores it The evidence never appeared on a card. PocketBase rewrites an uploaded filename: it splits at the first dot and inserts a random token, then flattens everything that is not a letter or a digit and collapses the runs. So signin.happy__home.png arrived first as signin_lbrsqmmxo0.happy__home.png -- mangled past recognition, with signin.wrong-password losing six characters of its middle -- and after the dots came out, as signin_happy_home_czik8h4h7b.png. Both sides are normalised the same way now rather than trusting a name to survive a round trip. Co-Authored-By: Claude Opus 5 --- pb_public/status.html | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pb_public/status.html b/pb_public/status.html index 46acd4c..4ff61c6 100644 --- a/pb_public/status.html +++ b/pb_public/status.html @@ -706,15 +706,27 @@ function runVerdict(c){ return 'nic nebrání vydání'; } -function shotUrl(r, name){ - var hit = (r.shots || []).filter(function(f){ return f.indexOf(name) === 0; })[0]; +// PocketBase rewrites an uploaded filename: it flattens everything that is not +// a letter or a digit to "_", collapses runs of them, and appends a random +// token. So `signin.happy__home.png` arrives as `signin_happy_home_czik8h4h7b`. +// Matching therefore normalises both sides the same way rather than trusting the +// name to survive -- a prefix match on the raw name found nothing at all. +function normName(s){ + return String(s).toLowerCase().replace(/\.[a-z0-9]+$/, "").replace(/[^a-z0-9]+/g, "_"); +} + +function shotUrl(r, caseId, shotName){ + var want = normName(caseId + "_" + shotName); + var hit = (r.shots || []).filter(function(f){ + return normName(f).indexOf(want) === 0; + })[0]; return hit ? "/api/files/e2e_runs/" + r.id + "/" + hit : null; } function caseRow(r, c){ var shots = (c.evidence || []).filter(function(e){ return e.kind === "screenshot"; }); var pics = shots.map(function(s){ - var u = shotUrl(r, c.id + "__" + s.name); + var u = shotUrl(r, c.id, s.name); return u ? '
' + esc(s.name) + "
" : ""; }).join("");