Skip to content

Commit

Permalink
[patch] fixed bug in URI match/params
Browse files Browse the repository at this point in the history
  • Loading branch information
bnkamalesh committed Jun 16, 2022
1 parent 87fbc1b commit 64312ad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion route.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (r *Route) matchWithWildcard(requestURI string) (bool, map[string]string) {

uriParameter = append(uriParameter, fragment)
if currentFragment.isVariable {
params[currentFragment.fragment] = uriParameter[0]
params[currentFragment.fragment] = strings.Join(uriParameter, "/")
}

if !currentFragment.hasWildcard {
Expand Down
7 changes: 3 additions & 4 deletions route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,13 @@ func TestMatchWithWildcard(t *testing.T) {
}

uri := "/hello/world/how/are/you/static2/hello2/world2/how2/are2/you2/static2"
wantParams := map[string]string{}
matched, params := route.matchPath(uri)
if matched {
t.Errorf("Expected no match, got match")
return
}
if reflect.DeepEqual(params, wantParams) {
t.Errorf("Expected params %v, got %v", wantParams, params)
if params != nil {
t.Errorf("Expected params %v, got %v", nil, params)
return
}
})
Expand Down Expand Up @@ -193,7 +192,7 @@ func TestMatchWithWildcard(t *testing.T) {
t.Errorf("Expected match, got no match")
return
}
if reflect.DeepEqual(params, wantParams) {
if !reflect.DeepEqual(params, wantParams) {
t.Errorf("Expected params %v, got %v", wantParams, params)
return
}
Expand Down

0 comments on commit 64312ad

Please sign in to comment.