Skip to content

Commit

Permalink
refactor(store): replace euroFormat with regex (jef#2131)
Browse files Browse the repository at this point in the history
  • Loading branch information
Meyer Paul authored and erwinc1 committed Mar 31, 2021
1 parent 6f674e7 commit 13e1ada
Show file tree
Hide file tree
Showing 98 changed files with 1 addition and 99 deletions.
3 changes: 1 addition & 2 deletions src/store/includes-labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,8 @@ export async function getPrice(
const priceString = await extractPageContents(page, selector);

if (priceString) {
const priceSeparator = query.euroFormat ? /\./g : /,/g;
const price = Number.parseFloat(
priceString.replace(priceSeparator, '').match(/\d+/g)!.join('.')
priceString.replace(/\\.|\\,/g, '').match(/\d+/g)!.join('.') // eslint-disable-line
);

logger.debug('received price', price);
Expand Down
1 change: 0 additions & 1 deletion src/store/model/acompc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const AComPC: Store = {
},
maxPrice: {
container: '.price',
euroFormat: true,
},
outOfStock: [
{
Expand Down
1 change: 0 additions & 1 deletion src/store/model/adorama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export const Adorama: Store = {
},
maxPrice: {
container: '.your-price',
euroFormat: false,
},
},
links: [
Expand Down
1 change: 0 additions & 1 deletion src/store/model/akinformatica.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const Akinformatica: Store = {
],
maxPrice: {
container: '#PrezzoListinoIvatoLabel',
euroFormat: true,
},
outOfStock: [
{
Expand Down
1 change: 0 additions & 1 deletion src/store/model/allneeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const Allneeds: Store = {
},
maxPrice: {
container: 'span.price',
euroFormat: false,
},
outOfStock: {
container: '.amstockstatus',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/alternate-nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const AlternateNL: Store = {
},
maxPrice: {
container: 'div.price > span',
euroFormat: true,
},
outOfStock: {
container: '.stockStatus',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/alternate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const Alternate: Store = {
},
maxPrice: {
container: 'div.price > span',
euroFormat: true,
},
outOfStock: [
{
Expand Down
1 change: 0 additions & 1 deletion src/store/model/amazon-de-warehouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const AmazonDeWarehouse: Store = {
},
maxPrice: {
container: '.olpOfferPrice',
euroFormat: true,
},
outOfStock: [
{
Expand Down
1 change: 0 additions & 1 deletion src/store/model/amazon-de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const AmazonDe: Store = {
},
maxPrice: {
container: '#priceblock_ourprice',
euroFormat: true,
},
outOfStock: [
{
Expand Down
1 change: 0 additions & 1 deletion src/store/model/amazon-fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const AmazonFr: Store = {
},
maxPrice: {
container: '#priceblock_ourprice',
euroFormat: true,
},
outOfStock: [
{
Expand Down
1 change: 0 additions & 1 deletion src/store/model/amazon-it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const AmazonIt: Store = {
},
maxPrice: {
container: '#priceblock_ourprice',
euroFormat: true,
},
},
links: [
Expand Down
1 change: 0 additions & 1 deletion src/store/model/amazon-nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export const AmazonNl: Store = {
],
maxPrice: {
container: '#priceblock_ourprice',
euroFormat: true,
},
outOfStock: [
{
Expand Down
1 change: 0 additions & 1 deletion src/store/model/amd-ca.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const AmdCa: Store = {
},
maxPrice: {
container: '.product-page-description h4',
euroFormat: false,
},
},
links: [
Expand Down
1 change: 0 additions & 1 deletion src/store/model/amd-de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const AmdDe: Store = {
},
maxPrice: {
container: '.product-page-description h4',
euroFormat: true,
},
outOfStock: {
container: '.btn-radeon',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/amd-it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const AmdIt: Store = {
},
maxPrice: {
container: '.product-page-description h4',
euroFormat: true,
},
},
links: [
Expand Down
1 change: 0 additions & 1 deletion src/store/model/amd-uk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const AmdUk: Store = {
],
maxPrice: {
container: '.product-page-description h4',
euroFormat: false,
},
outOfStock: [
{
Expand Down
1 change: 0 additions & 1 deletion src/store/model/amd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const Amd: Store = {
},
maxPrice: {
container: '.product-page-description h4',
euroFormat: false,
},
},
links: [
Expand Down
1 change: 0 additions & 1 deletion src/store/model/antonline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const AntOnline: Store = {
},
maxPrice: {
container: '.cPrice',
euroFormat: false,
},
outOfStock: {
container: '.priceView-price .priceView-hero-price span',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/aria.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const Aria: Store = {
},
maxPrice: {
container: '.priceBig',
euroFormat: false, // Note: Aria uses non-euroFromat as price seperator
},
outOfStock: {
container: '.fBox',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/arlt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const Arlt: Store = {
},
maxPrice: {
container: '.articleprice .price',
euroFormat: true,
},
outOfStock: {
container: '.articleDesc .shippingtext',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/awd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const Awd: Store = {
},
maxPrice: {
container: '.ty-price',
euroFormat: false, // Note: Awd uses non-euroFromat as price seperator
},
outOfStock: {
container: '.vs-stock.ty-float-left',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/azerty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const Azerty: Store = {
},
maxPrice: {
container: '.mod_article .price',
euroFormat: true,
},
outOfStock: {
container: '.orderdelay',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/bandh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const BAndH: Store = {
},
maxPrice: {
container: 'div[data-selenium="pricingPrice"]',
euroFormat: false,
},
outOfStock: {
container: 'button[data-selenium="notifyAvailabilityButton"]',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/bestbuy-ca.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export const BestBuyCa: Store = {
labels: {
maxPrice: {
container: 'div[class*="pricingContainer"]',
euroFormat: false,
},
outOfStock: {
container: '.addToCartButton:disabled',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const Box: Store = {
},
maxPrice: {
container: '.p-price',
euroFormat: false, // Note: Box uses non-euroFromat as price seperator
},
outOfStock: {
container: '#divBuyButton',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/bpctech.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const Bpctech: Store = {
},
maxPrice: {
container: 'div.price-box.price-final_price > span > span',
euroFormat: false,
},
},
links: [
Expand Down
1 change: 0 additions & 1 deletion src/store/model/bpmpower.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const BpmPower: Store = {
},
maxPrice: {
container: 'p.prezzoScheda:nth-child(1)',
euroFormat: true,
},
outOfStock: {
container: '.dispoSiProd >span',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/canadacomputers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const CanadaComputers: Store = {
},
maxPrice: {
container: '.h2-big > strong:nth-child(1)',
euroFormat: false,
},
},
links: [
Expand Down
1 change: 0 additions & 1 deletion src/store/model/caseking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const Caseking: Store = {
},
maxPrice: {
container: '#buybox .article_details_price',
euroFormat: true,
},
outOfStock: {
container: '.delivery_container',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/ccl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const Ccl: Store = {
},
maxPrice: {
container: '#pnlPriceText > p',
euroFormat: false, // Note: CCL uses non-euroFromat as price seperator
},
outOfStock: {
container: '#pnlSoldOut',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/centrecom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const Centrecom: Store = {
},
maxPrice: {
container: 'div.prod_price_current.product-price > span',
euroFormat: false,
},
outOfStock: {
container: '.prod_stores_stock > li:nth-child(1) > span:nth-child(2)',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/computeralliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const ComputerAlliance: Store = {
},
maxPrice: {
container: 'span.price',
euroFormat: false,
},
outOfStock: {
container:
Expand Down
1 change: 0 additions & 1 deletion src/store/model/computeruniverse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export const Computeruniverse: Store = {
},
maxPrice: {
container: '.product-price',
euroFormat: true,
},
outOfStock: {
container: '.availability',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/coolblue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const Coolblue: Store = {
},
maxPrice: {
container: '.js-order-block .sales-price__current',
euroFormat: true,
},
outOfStock: {
container: '.product-order',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/coolmod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const Coolmod: Store = {
},
maxPrice: {
container: '.text-price-total',
euroFormat: true,
},
outOfStock: {
container: '.product-availability',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/corsair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const Corsair: Store = {
},
maxPrice: {
container: '.product-price',
euroFormat: false,
},
},
links: [
Expand Down
1 change: 0 additions & 1 deletion src/store/model/currys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const Currys: Store = {
},
maxPrice: {
container: '#product-actions span[class*="ProductPriceBlock__Price"]',
euroFormat: false, // Note: Currys uses non-euroFromat as price seperator
},
outOfStock: {
container: '#product-actions .unavailable',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/cyberport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const Cyberport: Store = {
},
maxPrice: {
container: '#productDetailOverview .price',
euroFormat: true,
},
outOfStock: {
container: '.tooltipAvailabilityParent',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/dcomp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const Dcomp: Store = {
},
maxPrice: {
container: '#prodprice',
euroFormat: false,
},
outOfStock: {
container: '#cart-info > button.btn.notifyMe',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/drako.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const Drako: Store = {
],
maxPrice: {
container: '.price',
euroFormat: true,
},
},
links: [
Expand Down
1 change: 0 additions & 1 deletion src/store/model/ebuyer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const Ebuyer: Store = {
},
maxPrice: {
container: '.purchase-info__price .price',
euroFormat: false, // Note: ebuyer uses non-euroFromat as price seperator
},
outOfStock: {
container: '.purchase-info',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/elcorteingles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export const Elcorteingles: Store = {
],
maxPrice: {
container: '.product_detail-buy-price-container .price._big',
euroFormat: true,
},
outOfStock: [
{
Expand Down
1 change: 0 additions & 1 deletion src/store/model/eprice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const Eprice: Store = {
},
maxPrice: {
container: '#PrezzoClasic span[class*="big"]',
euroFormat: true,
},
outOfStock: {
container: '.dispo',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/equippr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const Equippr: Store = {
},
maxPrice: {
container: '.product--price',
euroFormat: true,
},
outOfStock: {
container: '.product--buybox',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/euronics-de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const EuronicsDE: Store = {
},
maxPrice: {
container: '.price--content',
euroFormat: true,
},
outOfStock: {
container:
Expand Down
1 change: 0 additions & 1 deletion src/store/model/evatech.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const Evatech: Store = {
},
maxPrice: {
container: '.product_detail_price',
euroFormat: false,
},
outOfStock: {
container: '.product_detail_add_to_cart > div:nth-child(2)',
Expand Down
1 change: 0 additions & 1 deletion src/store/model/expert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const Expert: Store = {
],
maxPrice: {
container: '.widget-Container-subContent .widget-ArticlePrice-price',
euroFormat: false,
},
outOfStock: [
{
Expand Down
1 change: 0 additions & 1 deletion src/store/model/futurex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const Futurex: Store = {
},
maxPrice: {
container: '.price',
euroFormat: true,
},
outOfStock: [
{
Expand Down
1 change: 0 additions & 1 deletion src/store/model/galaxus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const Galaxus: Store = {
},
maxPrice: {
container: '.productDetail .Z1c8',
euroFormat: true,
},
outOfStock: [
{
Expand Down
Loading

0 comments on commit 13e1ada

Please sign in to comment.