Skip to content

Commit

Permalink
Revert "accept dashes in variable names"
Browse files Browse the repository at this point in the history
This reverts commit be170be.

Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof authored and glours committed Sep 9, 2024
1 parent 4f02e42 commit aa1db26
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
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

0 comments on commit aa1db26

Please sign in to comment.