@times-components/ssr 2.59.38-8c13d97039c1ee721b5b9dbe12709bb98cd93d3d.2 → 2.59.38-c3f77517b357963002e883f8cb03f662f312dfb1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@times-components/ssr",
3
3
  "main": "src",
4
- "version": "2.59.38-8c13d97039c1ee721b5b9dbe12709bb98cd93d3d.2+8c13d97039",
4
+ "version": "2.59.38-c3f77517b357963002e883f8cb03f662f312dfb1.4+c3f77517b3",
5
5
  "scripts": {
6
6
  "bundle:dev": "yarn cleanup-dist && webpack --config=webpack.config.js",
7
7
  "bundle:prod": "yarn cleanup-dist && NODE_ENV=production webpack --config=webpack.config.js -p",
@@ -80,5 +80,5 @@
80
80
  "publishConfig": {
81
81
  "access": "public"
82
82
  },
83
- "gitHead": "8c13d97039c1ee721b5b9dbe12709bb98cd93d3d"
83
+ "gitHead": "c3f77517b357963002e883f8cb03f662f312dfb1"
84
84
  }
@@ -3,11 +3,15 @@ const {
3
3
  travelSiteCode,
4
4
  trackonomicsRegex
5
5
  } = require("../constants/affiliate-links-validation");
6
- /* const { wrapSkimlinks } = require("./skimlinks-wrapping"); */
6
+ const {
7
+ wrapSkimlinks,
8
+ fetchSkimlinksDomains,
9
+ filterDomains
10
+ } = require("./skimlinks-wrapping");
7
11
 
8
12
  const isAffiliateLink = url => trackonomicsRegex.test(url);
9
13
 
10
- const wrapAffiliateLink = (affiliateUrl, contentPageUrl) => {
14
+ const wrapAffiliateLink = (affiliateLink, contentPageUrl, filteredDomains) => {
11
15
  const wrapTrackonomics = trackonomicsUrl => {
12
16
  if (!isAffiliateLink(trackonomicsUrl)) {
13
17
  return trackonomicsUrl;
@@ -25,14 +29,20 @@ const wrapAffiliateLink = (affiliateUrl, contentPageUrl) => {
25
29
  return affiliateWrapper;
26
30
  };
27
31
 
28
- /* const skimlinksUrl = wrapSkimlinks(affiliateLink, contentPageUrl); */
29
- return wrapTrackonomics(affiliateUrl);
32
+ const skimlinksUrl = wrapSkimlinks(
33
+ affiliateLink,
34
+ contentPageUrl,
35
+ filteredDomains
36
+ );
37
+ return wrapTrackonomics(skimlinksUrl);
30
38
  };
31
39
 
32
- module.exports.affiliateLinksValidation = (children, articleDataFromRender) => {
40
+ const affiliateLinksValidation = async (children, articleDataFromRender) => {
33
41
  const clonedChildren = [...children];
34
42
  const { canonicalUrl, hostName } = articleDataFromRender;
35
43
  const contentPageUrl = `${hostName}${canonicalUrl}`;
44
+ const skimlinksDomains = await fetchSkimlinksDomains();
45
+ const filteredDomains = filterDomains(skimlinksDomains);
36
46
 
37
47
  const checkAndSetLinkTarget = elements =>
38
48
  elements.map(el => {
@@ -66,7 +76,7 @@ module.exports.affiliateLinksValidation = (children, articleDataFromRender) => {
66
76
  attributes: {
67
77
  ...attributes,
68
78
  target: "_blank",
69
- url: wrapAffiliateLink(href, contentPageUrl)
79
+ url: wrapAffiliateLink(href, contentPageUrl, filteredDomains)
70
80
  }
71
81
  };
72
82
  } else {
@@ -75,7 +85,7 @@ module.exports.affiliateLinksValidation = (children, articleDataFromRender) => {
75
85
  attributes: {
76
86
  ...attributes,
77
87
  target: "_blank",
78
- href: wrapAffiliateLink(href, contentPageUrl)
88
+ href: wrapAffiliateLink(href, contentPageUrl, filteredDomains)
79
89
  }
80
90
  };
81
91
  }
@@ -91,3 +101,5 @@ module.exports.affiliateLinksValidation = (children, articleDataFromRender) => {
91
101
 
92
102
  return checkAndSetLinkTarget(clonedChildren);
93
103
  };
104
+
105
+ module.exports = { affiliateLinksValidation };
@@ -66,9 +66,7 @@ const constructSkimlinksUrl = (merchantUrl, contentPageUrl) => {
66
66
  return skimlinksWrapper;
67
67
  };
68
68
 
69
- const wrapSkimlinks = async (url, contentPageUrl) => {
70
- const data = await fetchSkimlinksDomains();
71
- const filteredDomains = filterDomains(data);
69
+ const wrapSkimlinks = (url, contentPageUrl, filteredDomains) => {
72
70
  const skimlinksRegex = createDomainRegex(filteredDomains);
73
71
 
74
72
  if (skimlinksRegex.test(url)) {
@@ -79,5 +77,7 @@ const wrapSkimlinks = async (url, contentPageUrl) => {
79
77
  };
80
78
 
81
79
  module.exports = {
82
- wrapSkimlinks
80
+ wrapSkimlinks,
81
+ fetchSkimlinksDomains,
82
+ filterDomains
83
83
  };