diff --git a/config/options.go b/config/options.go index 28099ad02..b51a886b8 100644 --- a/config/options.go +++ b/config/options.go @@ -581,6 +581,9 @@ func (o *Options) Validate() error { } } + // strip quotes from redirect address (#811) + o.HTTPRedirectAddr = strings.Trim(o.HTTPRedirectAddr, `"'`) + RedirectAndAutocertServer.update(o) err = AutocertManager.update(o) diff --git a/config/options_test.go b/config/options_test.go index 67f640b4c..1d3e87afc 100644 --- a/config/options_test.go +++ b/config/options_test.go @@ -13,6 +13,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/spf13/viper" + "github.com/stretchr/testify/assert" ) var cmpOptIgnoreUnexported = cmpopts.IgnoreUnexported(Options{}) @@ -467,6 +468,14 @@ func TestOptions_sourceHostnames(t *testing.T) { } } +func TestHTTPRedirectAddressStripQuotes(t *testing.T) { + o := NewDefaultOptions() + o.InsecureServer = true + o.HTTPRedirectAddr = `":80"` + assert.NoError(t, o.Validate()) + assert.Equal(t, ":80", o.HTTPRedirectAddr) +} + func TestCompareByteSliceSlice(t *testing.T) { type Bytes = [][]byte