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

Revert "accept dashes in variable names" #680

Merged
merged 1 commit into from
Sep 9, 2024
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: 0 additions & 3 deletions dotenv/fixtures/special.env

This file was deleted.

8 changes: 0 additions & 8 deletions dotenv/godotenv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -691,14 +691,6 @@ func TestUTF8BOM(t *testing.T) {
loadEnvAndCompareValues(t, Load, envFileName, expectedValues, noopPresets)
}

func TestDash(t *testing.T) {
loadEnvAndCompareValues(t, Load, "fixtures/special.env", map[string]string{
"VAR-WITH-DASHES": "dashes",
"VAR.WITH.DOTS": "dots",
"VAR_WITH_UNDERSCORES": "underscores",
}, noopPresets)
}

func TestGetEnvFromFile(t *testing.T) {
wd := t.TempDir()
f := filepath.Join(wd, ".env")
Expand Down
2 changes: 1 addition & 1 deletion dotenv/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ loop:
offset = i + 1
inherited = rune == '\n'
break loop
case '_', '.', '-', '[', ']':
case '_', '.', '[', ']':
default:
// variable name should match [A-Za-z0-9_.-]
if unicode.IsLetter(rune) || unicode.IsNumber(rune) {
Expand Down
10 changes: 5 additions & 5 deletions dotenv/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ var testInput = `
a=b
a[1]=c
a.propertyKey=d
árvíztűrő-TÜKÖRFÚRÓGÉP=ÁRVÍZTŰRŐ-tükörfúrógép
árvíztűrőTÜKÖRFÚRÓGÉP=ÁRVÍZTŰRŐtükörfúrógép
`

func TestParseBytes(t *testing.T) {
p := newParser()

expectedOutput := map[string]string{
"a": "b",
"a[1]": "c",
"a.propertyKey": "d",
"árvíztűrő-TÜKÖRFÚRÓGÉP": "ÁRVÍZTŰRŐ-tükörfúrógép",
"a": "b",
"a[1]": "c",
"a.propertyKey": "d",
"árvíztűrőTÜKÖRFÚRÓGÉP": "ÁRVÍZTŰRŐtükörfúrógép",
}

out := map[string]string{}
Expand Down