@domql/utils 2.5.71 → 2.5.73
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/array.js +1 -0
- package/dist/cjs/array.js +2 -0
- package/dist/cjs/string.js +8 -5
- package/package.json +2 -2
- package/string.js +9 -5
package/array.js
CHANGED
package/dist/cjs/array.js
CHANGED
package/dist/cjs/string.js
CHANGED
|
@@ -36,13 +36,16 @@ const trimStringFromSymbols = (str, characters) => {
|
|
|
36
36
|
const pattern = new RegExp(`[${characters.join("\\")}]`, "g");
|
|
37
37
|
return str.replace(pattern, "");
|
|
38
38
|
};
|
|
39
|
-
const brackRegex =
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const brackRegex = {
|
|
40
|
+
2: /\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}/g,
|
|
41
|
+
3: /\{\{\s*((?:\.\.\.\/)+)?([^}\s]+)\s*\}\}/g
|
|
42
|
+
};
|
|
43
|
+
const replaceLiteralsWithObjectFields = (str, state, opts = {}) => {
|
|
44
|
+
if (!str.includes(opts.bracketsLength === 3 ? "{{{" : "{{"))
|
|
42
45
|
return str;
|
|
43
|
-
return str.replace(brackRegex, (_, parentPath, variable) => {
|
|
46
|
+
return str.replace(brackRegex[opts.bracketsLength || 2], (_, parentPath, variable) => {
|
|
44
47
|
if (parentPath) {
|
|
45
|
-
const parentLevels = parentPath.match(/\.\.\//g).length;
|
|
48
|
+
const parentLevels = parentPath.match(opts.bracketsLength === 3 ? /\.\.\.\//g : /\.\.\//g).length;
|
|
46
49
|
let parentState = state;
|
|
47
50
|
for (let i = 0; i < parentLevels; i++) {
|
|
48
51
|
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.73",
|
|
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": "6180b8819c6ccf0dc60501220a05ae212df7f44d",
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/core": "^7.12.0"
|
|
29
29
|
}
|
package/string.js
CHANGED
|
@@ -24,12 +24,16 @@ export const trimStringFromSymbols = (str, characters) => {
|
|
|
24
24
|
* @param {object} state - The object containing the values to substitute.
|
|
25
25
|
* @returns {string} The modified string with placeholders replaced by values from the object.
|
|
26
26
|
*/
|
|
27
|
-
const brackRegex =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const brackRegex = {
|
|
28
|
+
2: /\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}/g,
|
|
29
|
+
3: /\{\{\s*((?:\.\.\.\/)+)?([^}\s]+)\s*\}\}/g
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const replaceLiteralsWithObjectFields = (str, state, opts = {}) => {
|
|
33
|
+
if (!str.includes(opts.bracketsLength === 3 ? '{{{' : '{{')) return str
|
|
34
|
+
return str.replace(brackRegex[opts.bracketsLength || 2], (_, parentPath, variable) => {
|
|
31
35
|
if (parentPath) {
|
|
32
|
-
const parentLevels = parentPath.match(/\.\.\//g).length
|
|
36
|
+
const parentLevels = parentPath.match(opts.bracketsLength === 3 ? /\.\.\.\//g : /\.\.\//g).length
|
|
33
37
|
let parentState = state
|
|
34
38
|
for (let i = 0; i < parentLevels; i++) {
|
|
35
39
|
parentState = parentState.parent
|