Skip to content
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

param empty , avoid out of range #204

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,12 @@ func (r *Router) DELETE(path string, handle Handle) {
// frequently used, non-standardized or custom methods (e.g. for internal
// communication with a proxy).
func (r *Router) Handle(method, path string, handle Handle) {
if path[0] != '/' {
panic("path must begin with '/' in path '" + path + "'")
if len(path) > 0 {
if path[0] != '/' {
panic("path must begin with '/' in path '" + path + "'")
}
} else {
panic("path can't be empty string")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"path must not be empty"? or just combine it into if len(path) < 1 || path[0] != '/' {

}

if r.trees == nil {
Expand Down