Skip to content

Commit

Permalink
fix: allow dots in env variable names
Browse files Browse the repository at this point in the history
This is to accommodate Java services that expect this format
(e.g. "some.var"). It's not expressly permitted in POSIX but is
apparently commonly used, so I see no reason to disallow it.
  • Loading branch information
edvald committed Sep 3, 2019
1 parent 8afa8f6 commit a8f7dd1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion garden-service/src/config/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export const absolutePathRegex = /^\/.*/ // Note: Only checks for the leading sl
// from https://stackoverflow.com/a/12311250/3290965
export const identifierRegex = /^(?![0-9]+$)(?!.*-$)(?!-)[a-z0-9-]{1,63}$/
export const userIdentifierRegex = /^(?!garden)(?=.{1,63}$)[a-z][a-z0-9]*(-[a-z0-9]+)*$/
export const envVarRegex = /^(?!garden)[a-z_][a-z0-9_]*$/i
export const envVarRegex = /^(?!garden)[a-z_][a-z0-9_\.]*$/i

export const joiIdentifierDescription =
"valid RFC1035/RFC1123 (DNS) label (may contain lowercase letters, numbers and dashes, must start with a letter, " +
Expand Down
1 change: 1 addition & 0 deletions garden-service/test/unit/src/config/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe("envVarRegex", () => {
"_2134",
"a_b_c",
"A_B_C_",
"some.var", // This is not strictly valid POSIX, but a bunch of Java services use this style
]
for (const tc of testCases) {
const result = envVarRegex.test(tc)
Expand Down

0 comments on commit a8f7dd1

Please sign in to comment.