Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow . in Environment Variable Names #2

Merged
merged 1 commit into from
Jan 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion envparse.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,12 @@ func parseLine(ln []byte) ([]byte, []byte, error) {
for _, v := range key[1:] {
switch {
case v == '_':
case v == '.':
case v >= 'A' && v <= 'Z':
case v >= 'a' && v <= 'z':
case v >= '0' && v <= '9':
default:
return nil, nil, fmt.Errorf("key characters must be [A-Za-z0-9_] but found %q", v)
return nil, nil, fmt.Errorf("key characters must be [A-Za-z0-9_.] but found %q", v)
}
}

Expand Down
1 change: 1 addition & 0 deletions envparse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func TestParseLine_OK(t *testing.T) {
{"EscapedUnicodeCombined", `U4="\u2318\uD83D\uDE01"`, "U4", "\U00002318\U0001F601"},
{"README.mdEscapedUnicode", `FOO="The template value\nmay have included\nsome newlines!\n\ud83d\udd25"`, "FOO", "The template value\nmay have included\nsome newlines!\n🔥"},
{"UnderscoreKey", "_=x' ' ", "_", "x "},
{"DottedKey", "FOO.BAR=x", "FOO.BAR", "x"},
{"README.md", `SOME_KEY = normal unquoted \text 'plus single quoted\' "\"double quoted " # EOL`, "SOME_KEY", `normal unquoted \text plus single quoted\ "double quoted `},
{"WindowsNewline", `w="\r\n"`, "w", "\r\n"},
}
Expand Down