From e9bbecfacecbccc08f359f2f2ee3f13d5e4e0c70 Mon Sep 17 00:00:00 2001 From: Pierce Lopez Date: Sat, 5 Aug 2017 12:48:36 -0400 Subject: [PATCH] options: gracefully report un-parsed upstream URL upstreamURL is a nil pointer if there is an error parsing --upstream --- options.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/options.go b/options.go index f1df916..e6c6c4e 100644 --- a/options.go +++ b/options.go @@ -142,14 +142,13 @@ func (o *Options) Validate() error { for _, u := range o.Upstreams { upstreamURL, err := url.Parse(u) if err != nil { - msgs = append(msgs, fmt.Sprintf( - "error parsing upstream=%q %s", - upstreamURL, err)) + msgs = append(msgs, fmt.Sprintf("error parsing upstream: %s", err)) + } else { + if upstreamURL.Path == "" { + upstreamURL.Path = "/" + } + o.proxyURLs = append(o.proxyURLs, upstreamURL) } - if upstreamURL.Path == "" { - upstreamURL.Path = "/" - } - o.proxyURLs = append(o.proxyURLs, upstreamURL) } for _, u := range o.SkipAuthRegex {