@times-components/ssr 2.59.38-c3f77517b357963002e883f8cb03f662f312dfb1.4 → 2.59.38-ead701343e666ee07c63d76a718327484fe4d06e.0

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-c3f77517b357963002e883f8cb03f662f312dfb1.4+c3f77517b3",
4
+ "version": "2.59.38-ead701343e666ee07c63d76a718327484fe4d06e.0+ead701343e",
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": "c3f77517b357963002e883f8cb03f662f312dfb1"
83
+ "gitHead": "ead701343e666ee07c63d76a718327484fe4d06e"
84
84
  }
@@ -3,15 +3,11 @@ const {
3
3
  travelSiteCode,
4
4
  trackonomicsRegex
5
5
  } = require("../constants/affiliate-links-validation");
6
- const {
7
- wrapSkimlinks,
8
- fetchSkimlinksDomains,
9
- filterDomains
10
- } = require("./skimlinks-wrapping");
6
+ const { wrapSkimlinks } = require("./skimlinks-wrapping");
11
7
 
12
8
  const isAffiliateLink = url => trackonomicsRegex.test(url);
13
9
 
14
- const wrapAffiliateLink = (affiliateLink, contentPageUrl, filteredDomains) => {
10
+ const wrapAffiliateLink = (affiliateLink, contentPageUrl) => {
15
11
  const wrapTrackonomics = trackonomicsUrl => {
16
12
  if (!isAffiliateLink(trackonomicsUrl)) {
17
13
  return trackonomicsUrl;
@@ -29,20 +25,14 @@ const wrapAffiliateLink = (affiliateLink, contentPageUrl, filteredDomains) => {
29
25
  return affiliateWrapper;
30
26
  };
31
27
 
32
- const skimlinksUrl = wrapSkimlinks(
33
- affiliateLink,
34
- contentPageUrl,
35
- filteredDomains
36
- );
28
+ const skimlinksUrl = wrapSkimlinks(affiliateLink, contentPageUrl);
37
29
  return wrapTrackonomics(skimlinksUrl);
38
30
  };
39
31
 
40
- const affiliateLinksValidation = async (children, articleDataFromRender) => {
32
+ module.exports.affiliateLinksValidation = (children, articleDataFromRender) => {
41
33
  const clonedChildren = [...children];
42
34
  const { canonicalUrl, hostName } = articleDataFromRender;
43
35
  const contentPageUrl = `${hostName}${canonicalUrl}`;
44
- const skimlinksDomains = await fetchSkimlinksDomains();
45
- const filteredDomains = filterDomains(skimlinksDomains);
46
36
 
47
37
  const checkAndSetLinkTarget = elements =>
48
38
  elements.map(el => {
@@ -76,7 +66,7 @@ const affiliateLinksValidation = async (children, articleDataFromRender) => {
76
66
  attributes: {
77
67
  ...attributes,
78
68
  target: "_blank",
79
- url: wrapAffiliateLink(href, contentPageUrl, filteredDomains)
69
+ url: wrapAffiliateLink(href, contentPageUrl)
80
70
  }
81
71
  };
82
72
  } else {
@@ -85,7 +75,7 @@ const affiliateLinksValidation = async (children, articleDataFromRender) => {
85
75
  attributes: {
86
76
  ...attributes,
87
77
  target: "_blank",
88
- href: wrapAffiliateLink(href, contentPageUrl, filteredDomains)
78
+ href: wrapAffiliateLink(href, contentPageUrl)
89
79
  }
90
80
  };
91
81
  }
@@ -101,5 +91,3 @@ const affiliateLinksValidation = async (children, articleDataFromRender) => {
101
91
 
102
92
  return checkAndSetLinkTarget(clonedChildren);
103
93
  };
104
-
105
- module.exports = { affiliateLinksValidation };
@@ -66,7 +66,9 @@ const constructSkimlinksUrl = (merchantUrl, contentPageUrl) => {
66
66
  return skimlinksWrapper;
67
67
  };
68
68
 
69
- const wrapSkimlinks = (url, contentPageUrl, filteredDomains) => {
69
+ const wrapSkimlinks = async (url, contentPageUrl) => {
70
+ const data = await fetchSkimlinksDomains();
71
+ const filteredDomains = filterDomains(data);
70
72
  const skimlinksRegex = createDomainRegex(filteredDomains);
71
73
 
72
74
  if (skimlinksRegex.test(url)) {
@@ -77,7 +79,5 @@ const wrapSkimlinks = (url, contentPageUrl, filteredDomains) => {
77
79
  };
78
80
 
79
81
  module.exports = {
80
- wrapSkimlinks,
81
- fetchSkimlinksDomains,
82
- filterDomains
82
+ wrapSkimlinks
83
83
  };