From 682ce21348bc622b51c762e357eb703e24a1207a Mon Sep 17 00:00:00 2001 From: Vince Zarola Date: Wed, 10 Apr 2019 12:07:16 +0100 Subject: [PATCH] Remove v1 hack from CanonicalFnAPIUrl The v1 API is no longer supported so we can now remove this hack. C.f. the discussion on fnproject/fn_go#30 and fnproject/fn#1347. --- provider/provider.go | 8 -------- provider/provider_test.go | 6 +++--- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/provider/provider.go b/provider/provider.go index cc601ed..606e538 100644 --- a/provider/provider.go +++ b/provider/provider.go @@ -57,14 +57,6 @@ func CanonicalFnAPIUrl(urlStr string) (*url.URL, error) { } } - //Remove /v1 from any paths here internal URL is now base URL - - if strings.HasSuffix(parseUrl.Path, "/v1") { - parseUrl.Path = strings.TrimSuffix(parseUrl.Path, "v1") - } else if strings.HasSuffix(parseUrl.Path, "/v1/") { - parseUrl.Path = strings.TrimSuffix(parseUrl.Path, "v1/") - } - return parseUrl, nil } diff --git a/provider/provider_test.go b/provider/provider_test.go index 8af0cec..a00bea5 100644 --- a/provider/provider_test.go +++ b/provider/provider_test.go @@ -12,14 +12,14 @@ func TestCanonicaliseUrlURL(t *testing.T) { port string path string }{ - {"http://localhost:8080/v1", "http", "localhost", "8080", "/"}, + {"http://localhost:8080/v1", "http", "localhost", "8080", "/v1"}, {"http://localhost:8080", "http", "localhost", "8080", ""}, {"http://localhost", "http", "localhost", "80", ""}, {"localhost", "http", "localhost", "80", ""}, {"localhost:8080", "http", "localhost", "8080", ""}, - {"localhost/v1", "http", "localhost", "80", "/"}, + {"localhost/v1", "http", "localhost", "80", "/v1"}, {"localhost/", "http", "localhost", "80", "/"}, - {"https://localhost/v1", "https", "localhost", "443", "/"}, + {"https://localhost/v1", "https", "localhost", "443", "/v1"}, {"https://someprovider/specificversion/withasubpath", "https", "someprovider", "443", "/specificversion/withasubpath"}, {"https://someprovider:450/specificversion/withasubpath", "https", "someprovider", "450", "/specificversion/withasubpath"}, }