From 9a25266fd48e903bc6af0df10e4aa887110b44c8 Mon Sep 17 00:00:00 2001 From: logan garrett Date: Wed, 6 Dec 2023 15:35:19 -0800 Subject: [PATCH] fix: use better url parsing --- oauth/authcode.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/oauth/authcode.go b/oauth/authcode.go index c69e3a2..c3c2a6f 100644 --- a/oauth/authcode.go +++ b/oauth/authcode.go @@ -244,8 +244,11 @@ func (ac *AuthorizationCodeTokenSource) Token() (*oauth2.Token, error) { } // strip protocol prefix from configured redirect url for local webserver - redirectServer := strings.TrimPrefix(ac.getRedirectUrl(), "https://") - redirectServer = strings.TrimPrefix(redirectServer, "http://") + u, err := url.Parse(ac.getRedirectUrl()) + if err != nil { + panic(err) + } + redirectServer := fmt.Sprintf("%s:%s", u.Hostname(), u.Port()) s := &http.Server{ Addr: redirectServer,