Skip to content

Commit

Permalink
Merge pull request #336 from ndeloof/dashes
Browse files Browse the repository at this point in the history
closes #310
  • Loading branch information
ndeloof authored Jan 5, 2023
2 parents b56ae2b + be170be commit e4c15da
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions dotenv/fixtures/special.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VAR.WITH.DOTS=dots
VAR_WITH_UNDERSCORES=underscores
VAR-WITH-DASHES=dashes
8 changes: 8 additions & 0 deletions dotenv/godotenv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,3 +718,11 @@ 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)
}
4 changes: 2 additions & 2 deletions dotenv/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ loop:
offset = i + 1
inherited = char == '\n'
break loop
case '_', '.':
case '_', '.', '-':
default:
// variable name should match [A-Za-z0-9_.]
// variable name should match [A-Za-z0-9_.-]
if unicode.IsLetter(rchar) || unicode.IsNumber(rchar) {
continue
}
Expand Down

0 comments on commit e4c15da

Please sign in to comment.