Skip to content

Commit c431f39

Browse files
authored
Bug: Handle slash suffix in route path (#11)
* delete log * delete suffix path * pr template
1 parent b1741b6 commit c431f39

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

.github/pull_request_template.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Description
2+
3+
please describe the purpose of the pull request, including any background context and links to related issues
4+
5+
If it resolves an existing issue, please include a link to the issue.
6+
7+
Fixes #issuenumber
8+
9+
# Type of change
10+
11+
- [ ] Bug fix (non-breaking change which fixes an issue)
12+
- [ ] New feature (non-breaking change which adds functionality)
13+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
14+
- [ ] This change requires a documentation update

group.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package pulse
22

3-
import "fmt"
4-
53
type Group struct {
64
Prefix string
75
Router *Router
@@ -19,7 +17,6 @@ func (g *Group) Use(middleware Middleware) {
1917
}
2018

2119
func (g *Group) GET(path string, handlers ...Handler) {
22-
fmt.Println(g.Prefix + path)
2320
g.Router.Get(g.Prefix+path, handlers...)
2421
}
2522

router.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ func (r *Route) match(path string) (bool, map[string]string) {
125125
parts := strings.Split(path, "/")
126126
routeParts := strings.Split(r.Path, "/")
127127

128+
if strings.HasSuffix(path, "/") {
129+
parts = parts[:len(parts)-1]
130+
}
131+
128132
if len(parts) != len(routeParts) {
129133
return false, nil
130134
}

0 commit comments

Comments
 (0)