@incanta/config
Advanced tools
Comparing version 0.1.9 to 0.1.10
@@ -103,13 +103,15 @@ "use strict"; | ||
const regexResult = value.matchAll(variableRegex); | ||
let result = value; | ||
for (const match of regexResult) { | ||
const keyToReplace = match[0].slice(2, match[0].length - 1); | ||
const value = this.tryGet(keyToReplace); | ||
if (value !== null) { | ||
obj = obj.replace(match[0], `${value}`); | ||
const newValue = this.tryGet(keyToReplace); | ||
if (newValue !== null) { | ||
result = result.replace(match[0], `${newValue}`); | ||
} | ||
} | ||
return result; | ||
}; | ||
// replace all ${value} with the value from the config | ||
if (typeof obj === "string") { | ||
replaceValue(obj); | ||
obj = replaceValue(obj); | ||
} | ||
@@ -121,4 +123,4 @@ else if (typeof obj === "object") { | ||
const value = curObj[property]; | ||
if (typeof value === "string") { | ||
replaceValue(value); | ||
if (typeof value === "string" && property !== "format") { | ||
curObj[property] = replaceValue(value); | ||
} | ||
@@ -125,0 +127,0 @@ else if (typeof value === "object") { |
{ | ||
"name": "@incanta/config", | ||
"version": "0.1.9", | ||
"version": "0.1.10", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "exports": { |
@@ -132,11 +132,15 @@ import merge from "lodash.merge"; | ||
const replaceValue = (value: string): void => { | ||
const replaceValue = (value: string): string => { | ||
const regexResult = value.matchAll(variableRegex); | ||
let result = value; | ||
for (const match of regexResult) { | ||
const keyToReplace = match[0].slice(2, match[0].length - 1); | ||
const value = this.tryGet<string | number | boolean>(keyToReplace); | ||
if (value !== null) { | ||
obj = obj.replace(match[0], `${value}`); | ||
const newValue = this.tryGet<string | number | boolean>(keyToReplace); | ||
if (newValue !== null) { | ||
result = result.replace(match[0], `${newValue}`); | ||
} | ||
} | ||
return result; | ||
}; | ||
@@ -146,3 +150,3 @@ | ||
if (typeof obj === "string") { | ||
replaceValue(obj); | ||
obj = replaceValue(obj); | ||
} else if (typeof obj === "object") { | ||
@@ -153,4 +157,4 @@ // walk the object and replace all strings with the value from the config | ||
const value = curObj[property]; | ||
if (typeof value === "string") { | ||
replaceValue(value); | ||
if (typeof value === "string" && property !== "format") { | ||
curObj[property] = replaceValue(value); | ||
} else if (typeof value === "object") { | ||
@@ -157,0 +161,0 @@ walkObject(value); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33376
583