api: add Client.BaseURL method

This commit is contained in:
presbrey 2024-09-03 17:24:28 -04:00
parent 50c05d57e0
commit 5f8338cd36
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())
}
})
}
}