@domql/utils 2.3.146 → 2.3.147

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.
@@ -33,16 +33,19 @@ const stringIncludesAny = (str, characters) => {
33
33
  const replaceLiteralsWithObjectFields = (str, state) => {
34
34
  return str.replace(/\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}/g, (_, parentPath, variable) => {
35
35
  if (parentPath) {
36
- const parentLevels = parentPath.split("../").filter(Boolean).length;
36
+ const parentLevels = parentPath.match(/\.\.\//g).length;
37
37
  let parentState = state;
38
38
  for (let i = 0; i < parentLevels; i++) {
39
39
  parentState = parentState.parent;
40
+ if (!parentState) {
41
+ return "";
42
+ }
40
43
  }
41
44
  const value = parentState[variable.trim()];
42
- return value ? `${value}` : "";
45
+ return value !== void 0 ? `${value}` : "";
43
46
  } else {
44
47
  const value = state[variable.trim()];
45
- return value ? `${value}` : "";
48
+ return value !== void 0 ? `${value}` : "";
46
49
  }
47
50
  });
48
51
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.3.146",
3
+ "version": "2.3.147",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "index.js",
@@ -23,7 +23,7 @@
23
23
  "@domql/key": "latest",
24
24
  "@domql/tags": "latest"
25
25
  },
26
- "gitHead": "96ed22cf144f9b80ad0532ce6af1393677b5249f",
26
+ "gitHead": "88a525ab8e7fca820d53bb0c284d36bd68f3a147",
27
27
  "devDependencies": {
28
28
  "@babel/core": "^7.12.0"
29
29
  }
package/string.js CHANGED
@@ -12,16 +12,19 @@ export const stringIncludesAny = (str, characters) => {
12
12
  export const replaceLiteralsWithObjectFields = (str, state) => {
13
13
  return str.replace(/\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}/g, (_, parentPath, variable) => {
14
14
  if (parentPath) {
15
- const parentLevels = parentPath.split('../').filter(Boolean).length
15
+ const parentLevels = parentPath.match(/\.\.\//g).length
16
16
  let parentState = state
17
17
  for (let i = 0; i < parentLevels; i++) {
18
18
  parentState = parentState.parent
19
+ if (!parentState) {
20
+ return '' // Return an empty string if the parent level doesn't exist
21
+ }
19
22
  }
20
23
  const value = parentState[variable.trim()]
21
- return value ? `${value}` : ''
24
+ return value !== undefined ? `${value}` : ''
22
25
  } else {
23
26
  const value = state[variable.trim()]
24
- return value ? `${value}` : ''
27
+ return value !== undefined ? `${value}` : ''
25
28
  }
26
29
  })
27
30
  }