From a4aa316909f26917ecfe00fe0286b0cfb84df397 Mon Sep 17 00:00:00 2001 From: Ernest Micklei Date: Tue, 28 Feb 2023 08:22:40 +0100 Subject: [PATCH] Revert "introduce MergePathStrategy" This reverts commit 709cf8010cbe0bf2af576728ca9883596f476c9a. --- route_builder.go | 19 +------------------ web_service_test.go | 10 +++++----- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/route_builder.go b/route_builder.go index dbfaf947..830ebf14 100644 --- a/route_builder.go +++ b/route_builder.go @@ -353,25 +353,8 @@ func (b *RouteBuilder) Build() Route { return route } -type MergePathStrategyFunc func(path1, path2 string) string - -var ( - // behavior 3.10.* - PathJoinStrategy = path.Join - - // behavior <= 3.9 - TrimSlashStrategy = func(path1, path2 string) string { - return strings.TrimRight(path1, "/") + "/" + strings.TrimLeft(path2, "/") - } - - // MergePathStrategy is the active strategy for merging a Route path when building the routing of all WebServices. - // The value is set to TrimSlashStrategy - // PathJoinStrategy is an alternative strategy that is more strict - MergePathStrategy = TrimSlashStrategy -) - func concatPath(path1, path2 string) string { - return MergePathStrategy(path1, path2) + return path.Join(path1, path2) } var anonymousFuncCount int32 diff --git a/web_service_test.go b/web_service_test.go index aa4ec082..d2218169 100644 --- a/web_service_test.go +++ b/web_service_test.go @@ -338,11 +338,11 @@ func TestClientWithAndWithoutTrailingSlash(t *testing.T) { wantCode int }{ // behavior before #520 - {url: "http://here.com/test", wantCode: 404}, - {url: "http://here.com/test/", wantCode: 200}, - // behavior #520 - // {url: "http://here.com/test", wantCode: 200}, - // {url: "http://here.com/test/", wantCode: 404}, + // {url: "http://here.com/test", wantCode: 404}, + // {url: "http://here.com/test/", wantCode: 200}, + // current behavior + {url: "http://here.com/test", wantCode: 200}, + {url: "http://here.com/test/", wantCode: 404}, } { t.Run(tt.url, func(t *testing.T) { httpRequest, _ := http.NewRequest("PUT", tt.url, nil)