Skip to content

Commit

Permalink
Bug: Handle slash suffix in route path (#11)
Browse files Browse the repository at this point in the history
* delete log

* delete suffix path

* pr template
  • Loading branch information
2hmad authored Apr 13, 2023
1 parent b1741b6 commit c431f39
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
14 changes: 14 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Description

please describe the purpose of the pull request, including any background context and links to related issues

If it resolves an existing issue, please include a link to the issue.

Fixes #issuenumber

# Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update
3 changes: 0 additions & 3 deletions group.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package pulse

import "fmt"

type Group struct {
Prefix string
Router *Router
Expand All @@ -19,7 +17,6 @@ func (g *Group) Use(middleware Middleware) {
}

func (g *Group) GET(path string, handlers ...Handler) {
fmt.Println(g.Prefix + path)
g.Router.Get(g.Prefix+path, handlers...)
}

Expand Down
4 changes: 4 additions & 0 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ func (r *Route) match(path string) (bool, map[string]string) {
parts := strings.Split(path, "/")
routeParts := strings.Split(r.Path, "/")

if strings.HasSuffix(path, "/") {
parts = parts[:len(parts)-1]
}

if len(parts) != len(routeParts) {
return false, nil
}
Expand Down

0 comments on commit c431f39

Please sign in to comment.