Description

https://github.com/gin-gonic/gin/blob/master/tree.go#L519

                if unescape {
                    if v, err := url.QueryUnescape(val); err == nil {
                        val = v
                    }
                }

Should we use url.PathUnescape here instead url.QueryUnescape? The difference is if we need to unescape the plus sign.

Comment From: ljluestc


func TestPathUnescape(t *testing.T) {
    router := gin.Default()

    router.GET("/test/:param", func(c *gin.Context) {
        param := c.Param("param")
        c.JSON(200, gin.H{"param": param})
    })

    tests := []struct {
        url      string
        expected string
    }{
        {"/test/hello+world", "hello+world"},
        {"/test/hello%2Bworld", "hello+world"},
    }

    for _, test := range tests {
        w := performRequest(router, "GET", test.url)
        assert.Equal(t, http.StatusOK, w.Code)
        assert.Contains(t, w.Body.String(), test.expected)
    }
}