mirror of
https://github.com/clucraft/PriceGhost.git
synced 2026-06-14 15:25:15 +02:00
Add Swiss franc (CHF) and improve Euro currency support
- Add CHF to currency detection patterns in priceParser - Add getCurrencySymbol helper in notifications service - Update all frontend price formatting to support CHF - Swiss francs display as "CHF 29.99" format Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
c2cec6d4f1
commit
4928d6b9d3
5 changed files with 25 additions and 9 deletions
|
|
@ -10,6 +10,8 @@ const currencyMap: Record<string, string> = {
|
|||
'£': 'GBP',
|
||||
'¥': 'JPY',
|
||||
'₹': 'INR',
|
||||
'Fr.': 'CHF',
|
||||
'CHF': 'CHF',
|
||||
'CAD': 'CAD',
|
||||
'AUD': 'AUD',
|
||||
'USD': 'USD',
|
||||
|
|
@ -21,8 +23,10 @@ const currencyMap: Record<string, string> = {
|
|||
const pricePatterns = [
|
||||
// $29.99 or $29,99 or $ 29.99
|
||||
/(?<currency>[$€£¥₹])\s*(?<price>[\d,]+\.?\d*)/,
|
||||
// 29.99 USD or 29,99 EUR
|
||||
/(?<price>[\d,]+\.?\d*)\s*(?<currency>USD|EUR|GBP|CAD|AUD|JPY|INR)/i,
|
||||
// CHF 29.99 or Fr. 29.99 (Swiss franc prefix)
|
||||
/(?<currency>CHF|Fr\.)\s*(?<price>[\d,]+\.?\d*)/i,
|
||||
// 29.99 USD or 29,99 EUR or 29.99 CHF
|
||||
/(?<price>[\d,]+\.?\d*)\s*(?<currency>USD|EUR|GBP|CAD|AUD|JPY|INR|CHF)/i,
|
||||
// Plain number with optional decimal (fallback)
|
||||
/(?<price>\d{1,3}(?:[,.\s]?\d{3})*(?:[.,]\d{2})?)/,
|
||||
];
|
||||
|
|
@ -89,7 +93,7 @@ export function extractPricesFromText(html: string): ParsedPrice[] {
|
|||
|
||||
// Match all price-like patterns in the HTML
|
||||
const allMatches = html.matchAll(
|
||||
/(?:[$€£¥₹])\s*[\d,]+\.?\d*|[\d,]+\.?\d*\s*(?:USD|EUR|GBP|CAD|AUD)/gi
|
||||
/(?:[$€£¥₹])\s*[\d,]+\.?\d*|(?:CHF|Fr\.)\s*[\d,]+\.?\d*|[\d,]+\.?\d*\s*(?:USD|EUR|GBP|CAD|AUD|CHF)/gi
|
||||
);
|
||||
|
||||
for (const match of allMatches) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue