@capillarytech/creatives-library 8.0.307-alpha.0 → 8.0.307

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.
@@ -153,6 +153,8 @@ export const COPY_OF = 'Copy of';
153
153
  export const UNSUBSCRIBE_TAG = 'unsubscribe';
154
154
  /** Whitespace-tolerant check for {{ unsubscribe }}-style tag in content. */
155
155
  export const UNSUBSCRIBE_TAG_REGEX = new RegExp(`\\{\\{\\s*${UNSUBSCRIBE_TAG}\\s*\\}\\}`);
156
+ /** Matches {{ ... }} and captures the inner tag content (for scanning content for tags). */
157
+ export const TAG_CONTENT_REGEX = /{{([^}]+)}}/g;
156
158
  export const ENTRY_TRIGGER_TAG_REGEX = /\bentryTrigger\.\w+(?:\.\w+)?(?:\(\w+\))?/g;
157
159
  export const SKIP_TAGS_REGEX_GROUPS = ["dynamic_expiry_date_after_\\d+_days.FORMAT_\\d", "unsubscribe\\(#[a-zA-Z\\d]{6}\\)", "Link_to_[a-zA-Z]", "SURVEY.*.TOKEN", "^[A-Za-z].*\\([a-zA-Z\\d]*\\)", "referral_unique_(code|url).*userid"];
158
160
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.307-alpha.0",
4
+ "version": "8.0.307",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -8,7 +8,7 @@
8
8
 
9
9
  import lodashForEach from 'lodash/forEach';
10
10
  import lodashCloneDeep from 'lodash/cloneDeep';
11
- import { ENTRY_TRIGGER_TAG_REGEX, SKIP_TAGS_REGEX_GROUPS, UNSUBSCRIBE_TAG, UNSUBSCRIBE_TAG_REGEX } from '../constants/unified';
11
+ import { ENTRY_TRIGGER_TAG_REGEX, SKIP_TAGS_REGEX_GROUPS, TAG_CONTENT_REGEX, UNSUBSCRIBE_TAG, UNSUBSCRIBE_TAG_REGEX } from '../constants/unified';
12
12
 
13
13
  const DEFAULT = 'default';
14
14
  const SUBTAGS = 'subtags';
@@ -46,7 +46,7 @@ export const validateTagsCore = ({
46
46
  ...(includeIsContentEmpty && { isContentEmpty: false }),
47
47
  };
48
48
 
49
- if (tags && tags.length && !isFullMode) {
49
+ if (tags?.length && !isFullMode) {
50
50
  if (initialMissingTags == null) {
51
51
  // Definition-based: same as original tagValidations (when caller does not pass initialMissingTags)
52
52
  lodashForEach(tags, ({
@@ -69,21 +69,21 @@ export const validateTagsCore = ({
69
69
  response.missingTags = [...initialMissingTags];
70
70
  }
71
71
 
72
- const regex = /{{([^}]+)}}/g;
73
- let match = regex.exec(contentForUnsubscribeScan);
72
+ TAG_CONTENT_REGEX.lastIndex = 0;
73
+ let match = TAG_CONTENT_REGEX.exec(contentForUnsubscribeScan);
74
74
  while (match !== null) {
75
- const tagValue = match[1].trim();
75
+ const tagValue = match[1]?.trim();
76
76
  const ifSkipped = skipTagsFn(tagValue);
77
- if (ifSkipped && tagValue.indexOf(UNSUBSCRIBE_TAG) !== -1) {
78
- const missingTagIndex = response.missingTags.indexOf(UNSUBSCRIBE_TAG);
77
+ if (ifSkipped && tagValue?.indexOf(UNSUBSCRIBE_TAG) !== -1) {
78
+ const missingTagIndex = response?.missingTags?.indexOf(UNSUBSCRIBE_TAG);
79
79
  if (missingTagIndex !== -1) {
80
- response.missingTags.splice(missingTagIndex, 1);
80
+ response?.missingTags?.splice(missingTagIndex, 1);
81
81
  }
82
82
  }
83
- match = regex.exec(contentForUnsubscribeScan);
83
+ match = TAG_CONTENT_REGEX.exec(contentForUnsubscribeScan);
84
84
  }
85
85
 
86
- if (response.missingTags.length > 0) {
86
+ if (response?.missingTags?.length > 0) {
87
87
  response.valid = false;
88
88
  }
89
89
  }
@@ -91,7 +91,7 @@ export const validateTagsCore = ({
91
91
  response.isBraceError = !validateIfTagClosed(contentForBraceCheck);
92
92
  if (response.isBraceError) {
93
93
  response.valid = false;
94
- } else if (response.missingTags.length > 0) {
94
+ } else if (response?.missingTags?.length > 0) {
95
95
  response.valid = false;
96
96
  }
97
97
  return response;