-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Set maxParam with SetParamNames #1535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,8 +60,6 @@ func TestJWTRace(t *testing.T) { | |
|
|
||
| func TestJWT(t *testing.T) { | ||
| e := echo.New() | ||
| r := e.Router() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be only cleanup and unrelated to the PR.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fix is the code added in #1463 which triggered #1492. Removed because it is no longer needed in this PR. |
||
| r.Add("GET", "/:jwt", func(echo.Context) error { return nil }) | ||
| handler := func(c echo.Context) error { | ||
| return c.String(http.StatusOK, "test") | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it safe to set values without checking for the length of pnames here?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Paramchecks the length, so it's OK.echo/context.go
Line 298 in f93ba1f
ParamValuesdoes not check the length, so setting a slice shorter than pnames will panic.echo/context.go
Line 317 in f93ba1f
However, in the documentation it is written to set the same number of values, so it seems to be understood as a specification.
https://echo.labstack.com/guide/testing#setting-path-params
SetParamValuesdoes not return an error, so if you want to fix it, you should check the length withParamValues.