diff --git a/helpers.go b/helpers.go index 6d6e49be..77907e6a 100644 --- a/helpers.go +++ b/helpers.go @@ -211,6 +211,11 @@ func getGroupPath(prefix, path string) string { if path == "/" { return prefix } + + if path[0] != '/' { + path = "/" + path + } + return utils.TrimRight(prefix, '/') + path } diff --git a/helpers_test.go b/helpers_test.go index b0d90aa6..45a34097 100644 --- a/helpers_test.go +++ b/helpers_test.go @@ -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