refactor(js): extract favicon module + add faviconHost tests (§3.1)
Sixth slice of the app.js split. Moves the favicon fetch/cache section
(faviconHost, saveEntryIcon, ensureEntryFavicon, backfillFavicons,
clearAllFavicons) to js/app.favicon.js. Pure declarations, no top-level
side effects → loads before app.js.
- Code moved byte-for-byte; no duplicate const; syntax OK on all 7 app parts.
- NEW: js/tests/favicon.test.js — 7 tests for faviconHost, the pure
URL→validated-hostname function that decides which domain is sent to the
DuckDuckGo proxy (a bug there leaks the wrong host). Covers scheme/www/
path/port stripping, non-hostname rejection, malformed dotting, unsafe
chars, and the 253-char DNS cap.
- Fixed an inaccurate source comment surfaced by the tests: it claimed raw
IPs "stay valid", but the TLD rule /\.[a-z]{2,}$/ rejects a numeric final
label, so IPs get no favicon lookup (fine). Test pins the real behaviour.
- Suite: 55 → 62 tests, all green. Assets regenerated (8 ordered JS files).
app.js: 11936 → 9790 lines (6 modules extracted).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+7
-4
@@ -238,11 +238,14 @@ réécriture des call-sites, risque quasi nul vs conversion en modules ES).
|
||||
RFC 6238)** ajoutés en même temps → extraction *et* nouvelle couverture.
|
||||
- ✅ `js/app.backup.js` extrait (auto-backup planifié) — byte-for-byte
|
||||
identique, chargé AVANT app.js (pures déclarations).
|
||||
- `app.js` : 11 936 → **9 900 lignes** (crypto + totp + import + backup + sync
|
||||
sortis — 5 modules).
|
||||
- Suite de tests : 42 → **55 tests**.
|
||||
- ✅ `js/app.favicon.js` extrait (fetch/cache favicons) — chargé AVANT app.js.
|
||||
**+7 tests `faviconHost`** (extraction hostname → décide quel domaine part
|
||||
vers DDG). A révélé un commentaire faux (IPs « valides » alors qu'elles
|
||||
sont rejetées par la règle TLD `[a-z]{2,}`) — corrigé.
|
||||
- `app.js` : 11 936 → **9 790 lignes** (6 modules sortis).
|
||||
- Suite de tests : 42 → **62 tests**.
|
||||
- Reste à extraire (grosses sections cohésives) : slideover, settings,
|
||||
quicksearch, autofill, favicons, vault-health…
|
||||
quicksearch, autofill, vault-health…
|
||||
- ✅ `node --check` en pré-étape de `BuildAssets.ps1` : **déjà fait** (cf. §3.2).
|
||||
|
||||
### 3.2 🟡 Aucun test automatisé — **partiellement adressé (2026-07-04)**
|
||||
|
||||
Reference in New Issue
Block a user