Merge 5f8338cd3685cee14033d552ff3319ac74cc5c43 into d7eb05b9361febead29a74e71ddffc2ebeff5302

This commit is contained in:
presbrey 2024-11-14 13:55:23 +08:00 committed by GitHub
commit e436ff0213
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View File

@ -378,3 +378,10 @@ func (c *Client) Version(ctx context.Context) (string, error) {
return version.Version, nil
}
// BaseURL returns the base URL of the client.
func (c *Client) BaseURL() *url.URL {
// make a copy of the base URL to prevent mutation
base := *c.base
return &base
}

View File

@ -40,6 +40,9 @@ func TestClientFromEnvironment(t *testing.T) {
if client.base.String() != v.expect {
t.Fatalf("expected %s, got %s", v.expect, client.base.String())
}
if client.BaseURL().String() != v.expect {
t.Fatalf("expected %s, got %s", v.expect, client.BaseURL().String())
}
})
}
}