Skip to content

Commit 7c3df77

Browse files
committed
Revert "Allow parameter routes to end with a dot (/foo/:id.json)"
This reverts commit bfa1463.
1 parent 28d07c3 commit 7c3df77

File tree

2 files changed

+1
-9
lines changed

2 files changed

+1
-9
lines changed

router.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ func (r *Router) Find(method, path string, c Context) {
378378

379379
cn = child
380380
i, l := 0, len(search)
381-
for ; i < l && search[i] != '/' && search[i] != '.'; i++ {
381+
for ; i < l && search[i] != '/'; i++ {
382382
}
383383
pvalues[n] = search[:i]
384384
n++

router_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -784,9 +784,6 @@ func TestRouterParamNames(t *testing.T) {
784784
r.Add(GET, "/users/:id", func(c Context) error {
785785
return nil
786786
})
787-
r.Add(GET, "/companies/:id.json", func(c Context) error {
788-
return nil
789-
})
790787
r.Add(GET, "/users/:uid/files/:fid", func(c Context) error {
791788
return nil
792789
})
@@ -802,11 +799,6 @@ func TestRouterParamNames(t *testing.T) {
802799
assert.Equal(t, "id", c.pnames[0])
803800
assert.Equal(t, "1", c.Param("id"))
804801

805-
// Route -> /companies/:id.json
806-
r.Find(GET, "/companies/1.json", c)
807-
assert.Equal(t, "id", c.pnames[0])
808-
assert.Equal(t, "1", c.Param("id"))
809-
810802
// Route > /users/:uid/files/:fid
811803
r.Find(GET, "/users/1/files/1", c)
812804
assert.Equal(t, "uid", c.pnames[0])

0 commit comments

Comments
 (0)