Skip to content

Commit

Permalink
Fixed labstack#1052, dropped param alias feature
Browse files Browse the repository at this point in the history
Signed-off-by: Vishal Rana <[email protected]>
  • Loading branch information
vishr committed Jan 31, 2018
1 parent 67a5dcd commit ec048ea
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 28 deletions.
7 changes: 0 additions & 7 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,6 @@ func (c *context) Param(name string) string {
if n == name {
return c.pvalues[i]
}

// Param name with aliases
for _, p := range strings.Split(n, ",") {
if p == name {
return c.pvalues[i]
}
}
}
}
return ""
Expand Down
12 changes: 0 additions & 12 deletions context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,18 +303,6 @@ func TestContextPathParam(t *testing.T) {
assert.Equal(t, "501", c.Param("fid"))
}

func TestContextPathParamNamesAlais(t *testing.T) {
e := New()
req := httptest.NewRequest(GET, "/", nil)
c := e.NewContext(req, nil)

c.SetParamNames("id,name")
c.SetParamValues("joe")

assert.Equal(t, "joe", c.Param("id"))
assert.Equal(t, "joe", c.Param("name"))
}

func TestContextFormValue(t *testing.T) {
f := make(url.Values)
f.Set("name", "Jon Snow")
Expand Down
2 changes: 1 addition & 1 deletion middleware/rewrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type (

// Rules defines the URL path rewrite rules. The values captured in asterisk can be
// retrieved by index e.g. $1, $2 and so on.
// Examples:
// Example:
// "/old": "/new",
// "/api/*": "/$1",
// "/js/*": "/public/javascripts/$1",
Expand Down
8 changes: 0 additions & 8 deletions router.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package echo

import "strings"

type (
// Router is the registry of all registered routes for an `Echo` instance for
// request matching and URL path parameter parsing.
Expand Down Expand Up @@ -175,12 +173,6 @@ func (r *Router) insert(method, path string, h HandlerFunc, t kind, ppath string
if len(cn.pnames) == 0 { // Issue #729
cn.pnames = pnames
}
for i, n := range pnames {
// Param name aliases
if i < len(cn.pnames) && !strings.Contains(cn.pnames[i], n) {
cn.pnames[i] += "," + n
}
}
}
}
return
Expand Down

0 comments on commit ec048ea

Please sign in to comment.