Skip to content

Commit

Permalink
Revert "introduce MergePathStrategy"
Browse files Browse the repository at this point in the history
This reverts commit 709cf80.
  • Loading branch information
emicklei committed Feb 28, 2023
1 parent 709cf80 commit a4aa316
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 23 deletions.
19 changes: 1 addition & 18 deletions route_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions web_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a4aa316

Please sign in to comment.