tangled
alpha
login
or
join now
pds.ls
/
pdsls
398
fork
atom
atmosphere explorer
pds.ls
tool
typescript
atproto
398
fork
atom
overview
issues
1
pulls
pipelines
fix favicon fetch order
handle.invalid
14 hours ago
f84c03bb
21ae96cb
verified
This commit was signed with the committer's
known signature
.
handle.invalid
SSH Key Fingerprint:
SHA256:mBrT4x0JdzLpbVR95g1hjI1aaErfC02kmLRkPXwsYCk=
+13
-5
1 changed file
expand all
collapse all
unified
split
src
worker.js
+13
-5
src/worker.js
···
505
505
if (pageRes.ok && (pageRes.headers.get("content-type") ?? "").includes("text/html")) {
506
506
let bestHref = null;
507
507
let bestPriority = -1;
508
508
+
let bestSize = 0;
508
509
509
510
const rewriter = new HTMLRewriter().on("link", {
510
511
element(el) {
···
513
514
const href = el.getAttribute("href");
514
515
if (!href) return;
515
516
516
516
-
// Prefer apple-touch-icon > icon with sizes > icon > shortcut icon
517
517
+
// Prefer icon with sizes > icon > apple-touch-icon > shortcut icon
517
518
let priority = 0;
518
518
-
if (rel === "apple-touch-icon") priority = 3;
519
519
-
else if (rel === "icon" && el.getAttribute("sizes")) priority = 2;
520
520
-
else if (rel === "icon") priority = 1;
519
519
+
if (rel === "icon" && el.getAttribute("sizes")) priority = 3;
520
520
+
else if (rel === "icon") priority = 2;
521
521
+
else if (rel === "apple-touch-icon") priority = 1;
521
522
522
522
-
if (priority > bestPriority) {
523
523
+
const sizesAttr = el.getAttribute("sizes") ?? "";
524
524
+
const size = Math.max(...sizesAttr.split(/\s+/).map((s) => parseInt(s) || 0), 0);
525
525
+
526
526
+
if (
527
527
+
priority > bestPriority ||
528
528
+
(priority === bestPriority && size > bestSize && size <= 64)
529
529
+
) {
523
530
bestPriority = priority;
531
531
+
bestSize = size;
524
532
bestHref = href;
525
533
}
526
534
},