1
0
mirror of https://github.com/astaxie/beego.git synced 2024-06-02 06:53:28 +00:00
This commit is contained in:
Ming Deng 2020-09-11 23:48:21 +08:00
parent 6bbca96c6c
commit b575fa1ebe
3 changed files with 30 additions and 13 deletions

View File

@ -89,7 +89,7 @@ func (input *BeegoInput) URI() string {
// URL returns the request url path (without query, string and fragment).
func (input *BeegoInput) URL() string {
return input.Context.Request.URL.EscapedPath()
return input.Context.Request.URL.Path
}
// Site returns the base site url as scheme://domain type.

View File

@ -212,6 +212,23 @@ func TestAutoExtFunc(t *testing.T) {
}
}
func TestEscape(t *testing.T) {
r, _ := http.NewRequest("GET", "/search/%E4%BD%A0%E5%A5%BD", nil)
w := httptest.NewRecorder()
handler := NewControllerRegister()
handler.Get("/search/:keyword(.+)", func(ctx *context.Context) {
value := ctx.Input.Param(":keyword")
ctx.Output.Body([]byte(value))
})
handler.ServeHTTP(w, r)
str := w.Body.String()
if str != "你好" {
t.Errorf("incorrect, %s", str)
}
}
func TestRouteOk(t *testing.T) {
r, _ := http.NewRequest("GET", "/person/anderson/thomas?learn=kungfu", nil)