Skip to content

Commit 2493ce0

Browse files
committed
chore!: simplify regexp, remove replacement for env vars with dots
1 parent d46188a commit 2493ce0

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

src/utils/__tests__/config.test.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,4 @@ describe("injectEnv", () => {
9797
const result = await injectEnv({})
9898
expect(result).toEqual({})
9999
})
100-
101-
it("should handle env variables with dots in the name", async () => {
102-
process.env["TEST.VAR.WITH.DOTS"] = "dottedValue"
103-
const configString = "Value: ${env:TEST.VAR.WITH.DOTS}"
104-
const expectedString = "Value: dottedValue"
105-
const result = await injectEnv(configString)
106-
expect(result).toBe(expectedString)
107-
})
108100
})

src/utils/config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ export async function injectEnv(config: string | Record<PropertyKey, any>, notFo
1111
const isObject = typeof config === "object"
1212
let _config = isObject ? JSON.stringify(config) : config
1313

14-
_config = _config.replace(/\$\{env:([\w\.]+)\}/g, (_, name) => {
14+
_config = _config.replace(/\$\{env:([\w]+)\}/g, (_, name) => {
1515
// Check if null or undefined
16+
// intentionally using == to match null | undefined
17+
// eslint-disable-next-line eqeqeq
1618
if (process.env[name] == null)
1719
console.warn(`[injectEnv] env variable ${name} referenced but not found in process.env`)
1820

0 commit comments

Comments
 (0)