Skip to content
Myr

fix the misplacement of adding slashes (#2847)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by 市民233 · committed by GitHub · parent eb75ce0 · Browse files · 2 files+17 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+17 added−1 removed

  • other:+17 added−1 removed

2 files+17 added−1 removed

modified:routes_test.go+15 added
479 unmodified lines
480 router = New()481 router.GET("/a", func(c *Context) {})482 w = performRequest(router, http.MethodGet, "/")483 assert.Equal(t, http.StatusNotFound, w.Code)484485 // Reproduction test for the bug of issue #2843486 router = New()487 router.NoRoute(func(c *Context) {488 if c.Request.RequestURI == "/login" {489 c.String(200, "login")490 }491 })492 router.GET("/logout", func(c *Context) {493 c.String(200, "logout")494 })495 w = performRequest(router, http.MethodGet, "/login")496 assert.Equal(t, "login", w.Body.String())497 w = performRequest(router, http.MethodGet, "/logout")498 assert.Equal(t, "logout", w.Body.String())499}500501func TestRouterStaticFSNotFound(t *testing.T) {502 router := New()
136 unmodified lines
modified:tree.go+2 added-1 removed
632 unmodified lines
633634 // Nothing found. We can recommend to redirect to the same URL with an635 // extra trailing slash if a leaf exists for that path636 value.tsr = path == "/" ||637 (len(prefix) == len(path)+1 && n.handlers != nil)637 (len(prefix) == len(path)+1 && prefix[len(path)] == '/' &&638 path == prefix[:len(prefix)-1] && n.handlers != nil)639 return640 }641}642
224 unmodified lines