Skip to content

Commit

Permalink
Allow environment variables to start with underscores (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
sethvargo authored Feb 12, 2025
1 parent bbaf784 commit 05a905f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion envconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ func validateEnvName(s string) bool {
}

for i, r := range s {
if (i == 0 && !isLetter(r)) || (!isLetter(r) && !isNumber(r) && r != '_') {
if (i == 0 && !isLetter(r) && r != '_') || (!isLetter(r) && !isNumber(r) && r != '_') {
return false
}
}
Expand Down
5 changes: 5 additions & 0 deletions envconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3071,6 +3071,11 @@ func TestValidateEnvName(t *testing.T) {
in: "FOO",
exp: true,
},
{
name: "underscore_start",
in: "_foo",
exp: true,
},
{
name: "emoji_middle",
in: "FOO🚀",
Expand Down

0 comments on commit 05a905f

Please sign in to comment.