Lots of URL normalization.
So it doesn't matter if you have a trailing / or not.
diff --git a/openstack/utils/choose_version.go b/openstack/utils/choose_version.go
index 57e2a81..402a870 100644
--- a/openstack/utils/choose_version.go
+++ b/openstack/utils/choose_version.go
@@ -75,18 +75,19 @@
}
return endpoint
}
+ normalizedGiven := normalize(identityEndpoint)
for _, value := range resp.Versions.Values {
href := ""
for _, link := range value.Links {
if link.Rel == "self" {
- href = link.Href
+ href = normalize(link.Href)
}
}
if matching, ok := byID[value.ID]; ok {
// Prefer a version that exactly matches the provided endpoint.
- if normalize(href) == normalize(identityEndpoint) {
+ if href == normalizedGiven {
if href == "" {
return nil, "", fmt.Errorf("Endpoint missing in version %s response from %s", value.ID, normalized)
}
diff --git a/openstack/utils/choose_version_test.go b/openstack/utils/choose_version_test.go
index 4a8a443..b724ee8 100644
--- a/openstack/utils/choose_version_test.go
+++ b/openstack/utils/choose_version_test.go
@@ -53,7 +53,7 @@
t.Errorf("Expected %#v to win, but %#v did instead", v3, v)
}
- expected := testhelper.Endpoint() + "v3.0"
+ expected := testhelper.Endpoint() + "v3.0/"
if endpoint != expected {
t.Errorf("Expected endpoint [%s], but was [%s] instead", expected, endpoint)
}
@@ -76,7 +76,7 @@
t.Errorf("Expected %#v to win, but %#v did instead", v2, v)
}
- expected := testhelper.Endpoint() + "v2.0"
+ expected := testhelper.Endpoint() + "v2.0/"
if endpoint != expected {
t.Errorf("Expected endpoint [%s], but was [%s] instead", expected, endpoint)
}