File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -158,11 +158,12 @@ func getOptionalPaths(path string) []string {
158
158
newParam = true
159
159
} else if i > 0 && newParam && c == '?' {
160
160
p := strings .Replace (path [:index ], "?" , "" , - 1 )
161
+ p = p [:len (p )- 1 ]
161
162
if ! gotils .StringSliceInclude (paths , p ) {
162
163
paths = append (paths , p )
163
164
}
164
165
165
- p = strings .Replace (path [:i ], "?" , "" , - 1 ) + "/"
166
+ p = strings .Replace (path [:i ], "?" , "" , - 1 )
166
167
if ! gotils .StringSliceInclude (paths , p ) {
167
168
paths = append (paths , p )
168
169
}
Original file line number Diff line number Diff line change @@ -99,12 +99,12 @@ func TestGetOptionalPath(t *testing.T) {
99
99
}
100
100
101
101
expectedPaths := []string {
102
- "/show/:name/ " ,
103
- "/show/:name/:surname/ " ,
104
- "/show/:name/:surname/at/ " ,
105
- "/show/:name/:surname/at/:address/ " ,
106
- "/show/:name/:surname/at/:address/:id/ " ,
107
- "/show/:name/:surname/at/:address/:id/:phone/ " ,
102
+ "/show/:name" ,
103
+ "/show/:name/:surname" ,
104
+ "/show/:name/:surname/at" ,
105
+ "/show/:name/:surname/at/:address" ,
106
+ "/show/:name/:surname/at/:address/:id" ,
107
+ "/show/:name/:surname/at/:address/:id/:phone" ,
108
108
}
109
109
r := New ()
110
110
r .GET ("/show/:name/:surname?/at/:address?/:id/:phone?" , handler )
You can’t perform that action at this time.
0 commit comments