@domql/utils 2.5.73 → 2.5.76
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/dist/cjs/string.js +6 -5
- package/package.json +2 -2
- package/string.js +6 -5
package/dist/cjs/string.js
CHANGED
|
@@ -38,14 +38,15 @@ const trimStringFromSymbols = (str, characters) => {
|
|
|
38
38
|
};
|
|
39
39
|
const brackRegex = {
|
|
40
40
|
2: /\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}/g,
|
|
41
|
-
3: /\{\{\s*((
|
|
41
|
+
3: /\{\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}\}/g
|
|
42
42
|
};
|
|
43
|
-
const replaceLiteralsWithObjectFields = (str, state,
|
|
44
|
-
if (!str.includes(
|
|
43
|
+
const replaceLiteralsWithObjectFields = (str, state, options = {}) => {
|
|
44
|
+
if (!str.includes(options.bracketsLength === 3 ? "{{{" : "{{"))
|
|
45
45
|
return str;
|
|
46
|
-
|
|
46
|
+
const reg = brackRegex[options.bracketsLength || 2];
|
|
47
|
+
return str.replace(reg, (_, parentPath, variable) => {
|
|
47
48
|
if (parentPath) {
|
|
48
|
-
const parentLevels = parentPath.match(
|
|
49
|
+
const parentLevels = parentPath.match(options.bracketsLength === 3 ? /\.\.\.\//g : /\.\.\//g).length;
|
|
49
50
|
let parentState = state;
|
|
50
51
|
for (let i = 0; i < parentLevels; i++) {
|
|
51
52
|
parentState = parentState.parent;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/utils",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.76",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"build": "yarn build:cjs",
|
|
24
24
|
"prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "767e48d9adb22095984c0feb21fd92f045cdfe4a",
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/core": "^7.12.0"
|
|
29
29
|
}
|
package/string.js
CHANGED
|
@@ -26,14 +26,15 @@ export const trimStringFromSymbols = (str, characters) => {
|
|
|
26
26
|
*/
|
|
27
27
|
const brackRegex = {
|
|
28
28
|
2: /\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}/g,
|
|
29
|
-
3: /\{\{\s*((
|
|
29
|
+
3: /\{\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}\}/g
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export const replaceLiteralsWithObjectFields = (str, state,
|
|
33
|
-
if (!str.includes(
|
|
34
|
-
|
|
32
|
+
export const replaceLiteralsWithObjectFields = (str, state, options = {}) => {
|
|
33
|
+
if (!str.includes(options.bracketsLength === 3 ? '{{{' : '{{')) return str
|
|
34
|
+
const reg = brackRegex[options.bracketsLength || 2]
|
|
35
|
+
return str.replace(reg, (_, parentPath, variable) => {
|
|
35
36
|
if (parentPath) {
|
|
36
|
-
const parentLevels = parentPath.match(
|
|
37
|
+
const parentLevels = parentPath.match(options.bracketsLength === 3 ? /\.\.\.\//g : /\.\.\//g).length
|
|
37
38
|
let parentState = state
|
|
38
39
|
for (let i = 0; i < parentLevels; i++) {
|
|
39
40
|
parentState = parentState.parent
|