mirror of https://github.com/gofiber/fiber.git
👷 Auto add '/' prefix for Group
parent
2604398cac
commit
bdfad180f7
|
@ -211,6 +211,11 @@ func getGroupPath(prefix, path string) string {
|
|||
if path == "/" {
|
||||
return prefix
|
||||
}
|
||||
|
||||
if path[0] != '/' {
|
||||
path = "/" + path
|
||||
}
|
||||
|
||||
return utils.TrimRight(prefix, '/') + path
|
||||
}
|
||||
|
||||
|
|
|
@ -155,6 +155,9 @@ func Test_Utils_getGroupPath(t *testing.T) {
|
|||
|
||||
res = getGroupPath("/v1/api/", "/")
|
||||
utils.AssertEqual(t, "/v1/api/", res)
|
||||
|
||||
res = getGroupPath("/v1/api", "group")
|
||||
utils.AssertEqual(t, "/v1/api/group", res)
|
||||
}
|
||||
|
||||
// go test -v -run=^$ -bench=Benchmark_Utils_ -benchmem -count=3
|
||||
|
|
Loading…
Reference in New Issue