Skip to content

Commit 756c9d6

Browse files
authored
Improve matching for recommended certificates
Enhance certificate recommendation matching by normalizing text and checking asset filenames.
1 parent bfbb469 commit 756c9d6

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

web/installer.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,31 @@ let installer = (function () {
229229
const recommended = await _getRecommendedCertificate();
230230
if (recommended) {
231231
// Try to find a release that mentions the recommended certificate in name, tag_name or body
232-
const found = releases.find(r => {
233-
const hay = ((r.name || "") + " " + (r.tag_name || "") + " " + (r.body || "")).toLowerCase();
234-
return hay.includes(recommended.toLowerCase());
235-
});
232+
const normalise = s =>
233+
s.toLowerCase()
234+
.replace(/[^a-z0-9]+/g, ' ')
235+
.trim();
236+
237+
const recNorm = normalise(recommended);
238+
239+
const found = releases.find(r => {
240+
const textHay = normalise(
241+
(r.name || "") + " " +
242+
(r.tag_name || "") + " " +
243+
(r.body || "")
244+
);
245+
246+
if (textHay.includes(recNorm)) return true;
247+
248+
// 🔥 CHECK ASSET FILENAMES (THIS WAS MISSING)
249+
if (Array.isArray(r.assets)) {
250+
return r.assets.some(a =>
251+
a.name && normalise(a.name).includes(recNorm)
252+
);
253+
}
254+
255+
return false;
256+
});
236257
if (found) {
237258
chosenRelease = found;
238259
console.log("Using release matched to recommended certificate:", chosenRelease.name || chosenRelease.tag_name);

0 commit comments

Comments
 (0)