Test the fix for https://github.com/gin-gonic/gin/pull/4415
(t *testing.T)
| 988 | |
| 989 | // Test the fix for https://github.com/gin-gonic/gin/pull/4415 |
| 990 | func TestLiteralColonWithRun(t *testing.T) { |
| 991 | SetMode(TestMode) |
| 992 | router := New() |
| 993 | |
| 994 | router.GET(`/test\:action`, func(c *Context) { |
| 995 | c.JSON(http.StatusOK, H{"path": "literal_colon"}) |
| 996 | }) |
| 997 | |
| 998 | router.updateRouteTrees() |
| 999 | |
| 1000 | w := httptest.NewRecorder() |
| 1001 | |
| 1002 | req, _ := http.NewRequest(http.MethodGet, "/test:action", nil) |
| 1003 | router.ServeHTTP(w, req) |
| 1004 | |
| 1005 | assert.Equal(t, http.StatusOK, w.Code) |
| 1006 | assert.Contains(t, w.Body.String(), "literal_colon") |
| 1007 | } |
| 1008 | |
| 1009 | func TestLiteralColonWithDirectServeHTTP(t *testing.T) { |
| 1010 | SetMode(TestMode) |