mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +02:00
allow whitespace in regex
This commit is contained in:
parent
5ac8bedce8
commit
56091a4186
@ -57,7 +57,7 @@ func RewriteWithConfig(config RewriteConfig) echo.MiddlewareFunc {
|
||||
|
||||
// Initialize
|
||||
for k, v := range config.Rules {
|
||||
k = strings.Replace(k, "*", "(\\S*)", -1)
|
||||
k = strings.Replace(k, "*", "(.*)", -1)
|
||||
config.rulesRegex[regexp.MustCompile(k)] = v
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,9 @@ func TestRewrite(t *testing.T) {
|
||||
req.URL.Path = "/users/jack/orders/1"
|
||||
e.ServeHTTP(rec, req)
|
||||
assert.Equal(t, "/user/jack/order/1", req.URL.Path)
|
||||
req.URL.Path = "/api/new users"
|
||||
e.ServeHTTP(rec, req)
|
||||
assert.Equal(t, "/new users", req.URL.Path)
|
||||
}
|
||||
|
||||
// Issue #1086
|
||||
|
Loading…
Reference in New Issue
Block a user