Skip to content

Commit

Permalink
fix env regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kus committed Apr 16, 2021
1 parent 1d5cf22 commit 372cffe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func LoadConfig(filename string) (Config, error) {
return config, nil
}

var defaultEnv = regexp.MustCompile(`\${(?P<name>[\w\.]{1,}):-(?P<value>[\w\.]*)}`)
var defaultEnv = regexp.MustCompile(`\${(?P<name>[\w\.]{1,}):-(?P<value>[\w\.:/]*)}`)

func expandEnv(data string) string {
vars := defaultEnv.FindAllStringSubmatch(data, -1)
Expand Down
4 changes: 4 additions & 0 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ func Test_expandEnv(t *testing.T) {
name: "test 4",
data: "${TEST3:-127.0.0.1}",
want: "127.0.0.1",
}, {
name: "test 5",
data: "${TEST3:-https://example.com:443/path/}",
want: "127.0.0.1",
},
}
for _, tt := range tests {
Expand Down

0 comments on commit 372cffe

Please sign in to comment.