fix: harden price scraping (findings 1, 2, 6)

Finding 1: parsePriceValue mishandled thousands separators — "1.299,00"
and "1,299.00" both parsed to 1.3. Both the meta-tag path and the
text-regex path now funnel through a single normalizeAmount() helper
that picks the last separator as the decimal one, and the text regex
also matches thousands-grouped amounts.

Finding 2: the text fallback read <script>/<style> contents via
$('body').text(); those elements are now stripped from a clone first.

Finding 6: the default fetch now uses a 15s AbortSignal.timeout and a
browser-like User-Agent, so one unresponsive host cannot stall the
whole sequential run. The fetchImpl injection point is unchanged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013gwc3aCiyQxmCWQke8RvEz
This commit is contained in:
Sjoerd de Vries
2026-09-05 15:49:56 +02:00
parent 862699d35b
commit 52c9947267
5 changed files with 92 additions and 7 deletions
+5
View File
@@ -0,0 +1,5 @@
<html><body>
<script>var config = {"fallbackPrice": "€9,99"};</script>
<style>.price:after { content: "€1,11"; }</style>
<p>Onze prijs: &euro;49,95 vandaag</p>
</body></html>