@@ -186,11 +186,17 @@ func main() {
186186 }
187187 bytes , err = exec .Command (gitPath , "config" , "--get-urlmatch" , "credential.oauthAuthURL" , urll ).Output ()
188188 if err == nil {
189- c .Endpoint .AuthURL , _ = url .JoinPath (urll , strings .TrimSpace (string (bytes )))
189+ c .Endpoint .AuthURL , err = urlResolveReference (urll , strings .TrimSpace (string (bytes )))
190+ if err != nil {
191+ log .Fatalln (err )
192+ }
190193 }
191194 bytes , err = exec .Command (gitPath , "config" , "--get-urlmatch" , "credential.oauthTokenURL" , urll ).Output ()
192195 if err == nil {
193- c .Endpoint .TokenURL , _ = url .JoinPath (urll , strings .TrimSpace (string (bytes )))
196+ c .Endpoint .TokenURL , err = urlResolveReference (urll , strings .TrimSpace (string (bytes )))
197+ if err != nil {
198+ log .Fatalln (err )
199+ }
194200 }
195201 bytes , err = exec .Command (gitPath , "config" , "--get-urlmatch" , "credential.oauthRedirectURL" , urll ).Output ()
196202 if err == nil {
@@ -275,7 +281,10 @@ func getToken(c oauth2.Config) (*oauth2.Token, error) {
275281 c .RedirectURL = server .URL
276282 } else {
277283 server = httptest .NewUnstartedServer (handler )
278- url , _ := url .Parse (c .RedirectURL )
284+ url , err := url .Parse (c .RedirectURL )
285+ if err != nil {
286+ log .Fatalln (err )
287+ }
279288 l , err := net .Listen ("tcp" , url .Host )
280289 if err != nil {
281290 log .Fatalln (err )
@@ -331,3 +340,15 @@ func generatePKCEParams() *authhandler.PKCEParams {
331340 Verifier : verifier ,
332341 }
333342}
343+
344+ func urlResolveReference (base , ref string ) (string , error ) {
345+ base1 , err := url .Parse (base )
346+ if err != nil {
347+ return "" , err
348+ }
349+ ref1 , err := url .Parse (ref )
350+ if err != nil {
351+ return "" , err
352+ }
353+ return base1 .ResolveReference (ref1 ).String (), nil
354+ }
0 commit comments