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 <noreply@anthropic.com>
This commit is contained in:
parent
96f346f775
commit
17d3be8892
1 changed files with 15 additions and 3 deletions
|
|
@ -706,15 +706,27 @@ function runVerdict(c){
|
|||
return '<span class="pill ok">nic nebrání vydání</span>';
|
||||
}
|
||||
|
||||
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 ? '<a href="' + u + '" target="_blank"><img loading="lazy" src="' + u +
|
||||
'"><div class="cap">' + esc(s.name) + "</div></a>" : "";
|
||||
}).join("");
|
||||
|
|
|
|||
Loading…
Reference in a new issue