Merge pull request #298 from authorizerdev/fix/url-parsing

fix: remove extra slash from host
This commit is contained in:
Lakhan Samani 2022-11-24 19:13:50 +05:30 committed by GitHub
commit c948c98e94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,12 +20,12 @@ func GetHost(c *gin.Context) string {
authorizerURL = "" authorizerURL = ""
} }
if authorizerURL != "" { if authorizerURL != "" {
return authorizerURL return strings.TrimSuffix(authorizerURL, "/")
} }
authorizerURL = c.Request.Header.Get("X-Authorizer-URL") authorizerURL = c.Request.Header.Get("X-Authorizer-URL")
if authorizerURL != "" { if authorizerURL != "" {
return authorizerURL return strings.TrimSuffix(authorizerURL, "/")
} }
scheme := c.Request.Header.Get("X-Forwarded-Proto") scheme := c.Request.Header.Get("X-Forwarded-Proto")
@ -33,7 +33,7 @@ func GetHost(c *gin.Context) string {
scheme = "http" scheme = "http"
} }
host := c.Request.Host host := c.Request.Host
return scheme + "://" + host return strings.TrimSuffix(scheme+"://"+host, "/")
} }
// GetHostName function returns hostname and port // GetHostName function returns hostname and port