rsapi/auth.go
func extractRedirectURL(resp *http.Response) (*url.URL, error) {
	var u *url.URL
	if resp.StatusCode > 299 && resp.StatusCode < 399 {
		loc := resp.Header.Get("Location")
		if loc != "" {
			var err error
			u, err = url.Parse(loc)
			if err != nil {
				return nil, fmt.Errorf("invalid Location header '%s': %s", loc, err)
			}
		}
	}
	return u, nil
}
func extractRedirectURL(resp *http.Response) (*url.URL, error) {
	var u *url.URL
	if resp.StatusCode > 299 && resp.StatusCode < 399 {
		loc := resp.Header.Get("Location")
		if loc != "" {
			var err error
			u, err = url.Parse(loc)
			if err != nil {
				return nil, fmt.Errorf("invalid Location header '%s': %s", loc, err)
			}
		}
	}
	return u, nil
}
// extractRedirectURL is a helper function that extracts the Location header from a redirect
// response. It returns nil if the header is missing, an error if it's malformed.