diff --git a/path.go b/path.go index 27f09f5f9e..927a97aaca 100644 --- a/path.go +++ b/path.go @@ -362,23 +362,15 @@ func findLastCharsetPosition(search string, charset []byte) int { // findNextCharsetPositionConstraint search the next char position from the charset // unlike findNextCharsetPosition, it takes care of constraint start-end chars to parse route pattern func findNextCharsetPositionConstraint(search string, charset []byte) int { + constraintStart := findNextNonEscapedCharsetPosition(search, parameterConstraintStartChars) + constraintEnd := findNextNonEscapedCharsetPosition(search, parameterConstraintEndChars) nextPosition := -1 - constraintStart := -1 - constraintEnd := -1 for _, char := range charset { pos := strings.IndexByte(search, char) - if char == paramConstraintStart { - constraintStart = pos - } - - if char == paramConstraintEnd { - constraintEnd = pos - } - if pos != -1 && (pos < nextPosition || nextPosition == -1) { - if pos > constraintStart && pos < constraintEnd { + if (pos > constraintStart && pos > constraintEnd) || (pos < constraintStart && pos < constraintEnd) { nextPosition = pos } } diff --git a/path_test.go b/path_test.go index ca02ea2b15..5e89e1a875 100644 --- a/path_test.go +++ b/path_test.go @@ -432,128 +432,128 @@ func Test_Path_matchParams(t *testing.T) { {url: "/api/:test", params: nil, match: false}, }) testCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, {url: "/api/v1/8728382", params: []string{"8728382"}, match: true}, - {url: "/api/v1/true", params: []string{"true"}, match: false}, + {url: "/api/v1/true", params: nil, match: false}, }) testCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, - {url: "/api/v1/8728382", params: []string{"8728382"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, + {url: "/api/v1/8728382", params: nil, match: false}, {url: "/api/v1/true", params: []string{"true"}, match: true}, }) testCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, {url: "/api/v1/8728382", params: []string{"8728382"}, match: true}, {url: "/api/v1/8728382.5", params: []string{"8728382.5"}, match: true}, - {url: "/api/v1/true", params: []string{"true"}, match: false}, + {url: "/api/v1/true", params: nil, match: false}, }) testCase("/api/v1/:param", []testparams{ {url: "/api/v1/entity", params: []string{"entity"}, match: true}, - {url: "/api/v1/#!?", params: []string{"#!?"}, match: false}, - {url: "/api/v1/8728382", params: []string{"8728382"}, match: false}, + {url: "/api/v1/#!?", params: nil, match: false}, + {url: "/api/v1/8728382", params: nil, match: false}, }) testCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, - {url: "/api/v1/8728382", params: []string{"8728382"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, + {url: "/api/v1/8728382", params: nil, match: false}, {url: "/api/v1/f0fa66cc-d22e-445b-866d-1d76e776371d", params: []string{"f0fa66cc-d22e-445b-866d-1d76e776371d"}, match: true}, }) testCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, - {url: "/api/v1/8728382", params: []string{"8728382"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, + {url: "/api/v1/8728382", params: nil, match: false}, }) testCase("/api/v1/:param", []testparams{ {url: "/api/v1/entity", params: []string{"entity"}, match: true}, - {url: "/api/v1/ent", params: []string{"ent"}, match: false}, + {url: "/api/v1/ent", params: nil, match: false}, {url: "/api/v1/8728382", params: []string{"8728382"}, match: true}, - {url: "/api/v1/123", params: []string{"123"}, match: false}, + {url: "/api/v1/123", params: nil, match: false}, {url: "/api/v1/12345", params: []string{"12345"}, match: true}, }) testCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, {url: "/api/v1/ent", params: []string{"ent"}, match: true}, - {url: "/api/v1/8728382", params: []string{"8728382"}, match: false}, + {url: "/api/v1/8728382", params: nil, match: false}, {url: "/api/v1/123", params: []string{"123"}, match: true}, {url: "/api/v1/12345", params: []string{"12345"}, match: true}, }) testCase("/api/v1/:param", []testparams{ - {url: "/api/v1/ent", params: []string{"ent"}, match: false}, - {url: "/api/v1/123", params: []string{"123"}, match: false}, + {url: "/api/v1/ent", params: nil, match: false}, + {url: "/api/v1/123", params: nil, match: false}, {url: "/api/v1/12345", params: []string{"12345"}, match: true}, }) testCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, - {url: "/api/v1/ent", params: []string{"ent"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, + {url: "/api/v1/ent", params: nil, match: false}, }) testCase("/api/v1/:param", []testparams{ - {url: "/api/v1/e", params: []string{"e"}, match: false}, + {url: "/api/v1/e", params: nil, match: false}, {url: "/api/v1/en", params: []string{"en"}, match: true}, - {url: "/api/v1/8728382", params: []string{"8728382"}, match: false}, + {url: "/api/v1/8728382", params: nil, match: false}, {url: "/api/v1/123", params: []string{"123"}, match: true}, {url: "/api/v1/12345", params: []string{"12345"}, match: true}, }) testCase("/api/v1/:param", []testparams{ - {url: "/api/v1/e", params: []string{"e"}, match: false}, + {url: "/api/v1/e", params: nil, match: false}, {url: "/api/v1/en", params: []string{"en"}, match: true}, - {url: "/api/v1/8728382", params: []string{"8728382"}, match: false}, + {url: "/api/v1/8728382", params: nil, match: false}, {url: "/api/v1/123", params: []string{"123"}, match: true}, {url: "/api/v1/12345", params: []string{"12345"}, match: true}, }) testCase("/api/v1/:param", []testparams{ - {url: "/api/v1/ent", params: []string{"ent"}, match: false}, - {url: "/api/v1/1", params: []string{"1"}, match: false}, + {url: "/api/v1/ent", params: nil, match: false}, + {url: "/api/v1/1", params: nil, match: false}, {url: "/api/v1/5", params: []string{"5"}, match: true}, }) testCase("/api/v1/:param", []testparams{ - {url: "/api/v1/ent", params: []string{"ent"}, match: false}, + {url: "/api/v1/ent", params: nil, match: false}, {url: "/api/v1/1", params: []string{"1"}, match: true}, {url: "/api/v1/5", params: []string{"5"}, match: true}, - {url: "/api/v1/15", params: []string{"15"}, match: false}, + {url: "/api/v1/15", params: nil, match: false}, }) testCase("/api/v1/:param", []testparams{ - {url: "/api/v1/ent", params: []string{"ent"}, match: false}, + {url: "/api/v1/ent", params: nil, match: false}, {url: "/api/v1/9", params: []string{"9"}, match: true}, {url: "/api/v1/5", params: []string{"5"}, match: true}, - {url: "/api/v1/15", params: []string{"15"}, match: false}, + {url: "/api/v1/15", params: nil, match: false}, }) testCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, - {url: "/api/v1/8728382", params: []string{"8728382"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, + {url: "/api/v1/8728382", params: nil, match: false}, {url: "/api/v1/2005-11-01", params: []string{"2005-11-01"}, match: true}, }) testCase("/api/v1/:param", []testparams{ - {url: "/api/v1/ent", params: []string{"ent"}, match: false}, - {url: "/api/v1/15", params: []string{"15"}, match: false}, + {url: "/api/v1/ent", params: nil, match: false}, + {url: "/api/v1/15", params: nil, match: false}, {url: "/api/v1/peach", params: []string{"peach"}, match: true}, - {url: "/api/v1/p34ch", params: []string{"p34ch"}, match: false}, + {url: "/api/v1/p34ch", params: nil, match: false}, }) testCase("/api/v1/:param", []testparams{ - {url: "/api/v1/ent", params: []string{"ent"}, match: false}, - {url: "/api/v1/15", params: []string{"15"}, match: false}, + {url: "/api/v1/ent", params: nil, match: false}, + {url: "/api/v1/15", params: nil, match: false}, {url: "/api/v1/2022-08-27", params: []string{"2022-08-27"}, match: true}, - {url: "/api/v1/2022/08-27", params: []string{"p34ch"}, match: false}, + {url: "/api/v1/2022/08-27", params: nil, match: false}, }) testCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, {url: "/api/v1/8728382", params: []string{"8728382"}, match: true}, - {url: "/api/v1/true", params: []string{"true"}, match: false}, + {url: "/api/v1/true", params: nil, match: false}, }) testCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, - {url: "/api/v1/8728382", params: []string{"8728382"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, + {url: "/api/v1/8728382", params: nil, match: false}, {url: "/api/v1/123", params: []string{"123"}, match: true}, - {url: "/api/v1/true", params: []string{"true"}, match: false}, + {url: "/api/v1/true", params: nil, match: false}, }) testCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, - {url: "/api/v1/87283827683", params: []string{"8728382"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, + {url: "/api/v1/87283827683", params: nil, match: false}, {url: "/api/v1/123", params: []string{"123"}, match: true}, - {url: "/api/v1/true", params: []string{"true"}, match: false}, + {url: "/api/v1/true", params: nil, match: false}, }) testCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, - {url: "/api/v1/87283827683", params: []string{"8728382"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, + {url: "/api/v1/87283827683", params: nil, match: false}, {url: "/api/v1/25", params: []string{"25"}, match: true}, - {url: "/api/v1/true", params: []string{"true"}, match: false}, + {url: "/api/v1/true", params: nil, match: false}, }) testCase("/api/v1/:param", []testparams{ {url: "/api/v1/entity", params: []string{"entity"}, match: true}, @@ -562,11 +562,40 @@ func Test_Path_matchParams(t *testing.T) { {url: "/api/v1/true", params: []string{"true"}, match: true}, }) testCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, - {url: "/api/v1/87283827683", params: []string{"8728382"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, + {url: "/api/v1/87283827683", params: nil, match: false}, {url: "/api/v1/25", params: []string{"25"}, match: true}, {url: "/api/v1/1200", params: []string{"1200"}, match: true}, - {url: "/api/v1/true", params: []string{"true"}, match: false}, + {url: "/api/v1/true", params: nil, match: false}, + }) + testCase("/api/v1/:lang/videos/:page", []testparams{ + {url: "/api/v1/try/videos/200", params: nil, match: false}, + {url: "/api/v1/tr/videos/1800", params: nil, match: false}, + {url: "/api/v1/tr/videos/100", params: []string{"tr", "100"}, match: true}, + {url: "/api/v1/e/videos/10", params: nil, match: false}, + }) + testCase("/api/v1/:lang/:page", []testparams{ + {url: "/api/v1/try/200", params: nil, match: false}, + {url: "/api/v1/tr/1800", params: nil, match: false}, + {url: "/api/v1/tr/100", params: []string{"tr", "100"}, match: true}, + {url: "/api/v1/e/10", params: nil, match: false}, + }) + testCase("/api/v1/:lang/:page", []testparams{ + {url: "/api/v1/try/200", params: []string{"try", "200"}, match: true}, + {url: "/api/v1/tr/1800", params: nil, match: false}, + {url: "/api/v1/tr/100", params: []string{"tr", "100"}, match: true}, + {url: "/api/v1/e/10", params: nil, match: false}, + }) + testCase("/api/v1/:lang/:page", []testparams{ + {url: "/api/v1/try/200", params: nil, match: false}, + {url: "/api/v1/tr/1800", params: []string{"tr", "1800"}, match: true}, + {url: "/api/v1/tr/100", params: []string{"tr", "100"}, match: true}, + {url: "/api/v1/e/10", params: nil, match: false}, + }) + testCase("/api/v1/:date/:regex", []testparams{ + {url: "/api/v1/2005-11-01/a", params: nil, match: false}, + {url: "/api/v1/2005-1101/paach", params: nil, match: false}, + {url: "/api/v1/2005-11-01/peach", params: []string{"2005-11-01", "peach"}, match: true}, }) } @@ -657,128 +686,128 @@ func Benchmark_Path_matchParams(t *testing.B) { {url: "/api/v1/", params: nil, match: false}, }) benchCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, {url: "/api/v1/8728382", params: []string{"8728382"}, match: true}, - {url: "/api/v1/true", params: []string{"true"}, match: false}, + {url: "/api/v1/true", params: nil, match: false}, }) benchCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, - {url: "/api/v1/8728382", params: []string{"8728382"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, + {url: "/api/v1/8728382", params: nil, match: false}, {url: "/api/v1/true", params: []string{"true"}, match: true}, }) benchCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, {url: "/api/v1/8728382", params: []string{"8728382"}, match: true}, {url: "/api/v1/8728382.5", params: []string{"8728382.5"}, match: true}, - {url: "/api/v1/true", params: []string{"true"}, match: false}, + {url: "/api/v1/true", params: nil, match: false}, }) benchCase("/api/v1/:param", []testparams{ {url: "/api/v1/entity", params: []string{"entity"}, match: true}, - {url: "/api/v1/#!?", params: []string{"#!?"}, match: false}, - {url: "/api/v1/8728382", params: []string{"8728382"}, match: false}, + {url: "/api/v1/#!?", params: nil, match: false}, + {url: "/api/v1/8728382", params: nil, match: false}, }) benchCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, - {url: "/api/v1/8728382", params: []string{"8728382"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, + {url: "/api/v1/8728382", params: nil, match: false}, {url: "/api/v1/f0fa66cc-d22e-445b-866d-1d76e776371d", params: []string{"f0fa66cc-d22e-445b-866d-1d76e776371d"}, match: true}, }) benchCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, - {url: "/api/v1/8728382", params: []string{"8728382"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, + {url: "/api/v1/8728382", params: nil, match: false}, }) benchCase("/api/v1/:param", []testparams{ {url: "/api/v1/entity", params: []string{"entity"}, match: true}, - {url: "/api/v1/ent", params: []string{"ent"}, match: false}, + {url: "/api/v1/ent", params: nil, match: false}, {url: "/api/v1/8728382", params: []string{"8728382"}, match: true}, - {url: "/api/v1/123", params: []string{"123"}, match: false}, + {url: "/api/v1/123", params: nil, match: false}, {url: "/api/v1/12345", params: []string{"12345"}, match: true}, }) benchCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, {url: "/api/v1/ent", params: []string{"ent"}, match: true}, - {url: "/api/v1/8728382", params: []string{"8728382"}, match: false}, + {url: "/api/v1/8728382", params: nil, match: false}, {url: "/api/v1/123", params: []string{"123"}, match: true}, {url: "/api/v1/12345", params: []string{"12345"}, match: true}, }) benchCase("/api/v1/:param", []testparams{ - {url: "/api/v1/ent", params: []string{"ent"}, match: false}, - {url: "/api/v1/123", params: []string{"123"}, match: false}, + {url: "/api/v1/ent", params: nil, match: false}, + {url: "/api/v1/123", params: nil, match: false}, {url: "/api/v1/12345", params: []string{"12345"}, match: true}, }) benchCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, - {url: "/api/v1/ent", params: []string{"ent"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, + {url: "/api/v1/ent", params: nil, match: false}, }) benchCase("/api/v1/:param", []testparams{ - {url: "/api/v1/e", params: []string{"e"}, match: false}, + {url: "/api/v1/e", params: nil, match: false}, {url: "/api/v1/en", params: []string{"en"}, match: true}, - {url: "/api/v1/8728382", params: []string{"8728382"}, match: false}, + {url: "/api/v1/8728382", params: nil, match: false}, {url: "/api/v1/123", params: []string{"123"}, match: true}, {url: "/api/v1/12345", params: []string{"12345"}, match: true}, }) benchCase("/api/v1/:param", []testparams{ - {url: "/api/v1/e", params: []string{"e"}, match: false}, + {url: "/api/v1/e", params: nil, match: false}, {url: "/api/v1/en", params: []string{"en"}, match: true}, - {url: "/api/v1/8728382", params: []string{"8728382"}, match: false}, + {url: "/api/v1/8728382", params: nil, match: false}, {url: "/api/v1/123", params: []string{"123"}, match: true}, {url: "/api/v1/12345", params: []string{"12345"}, match: true}, }) benchCase("/api/v1/:param", []testparams{ - {url: "/api/v1/ent", params: []string{"ent"}, match: false}, - {url: "/api/v1/1", params: []string{"1"}, match: false}, + {url: "/api/v1/ent", params: nil, match: false}, + {url: "/api/v1/1", params: nil, match: false}, {url: "/api/v1/5", params: []string{"5"}, match: true}, }) benchCase("/api/v1/:param", []testparams{ - {url: "/api/v1/ent", params: []string{"ent"}, match: false}, + {url: "/api/v1/ent", params: nil, match: false}, {url: "/api/v1/1", params: []string{"1"}, match: true}, {url: "/api/v1/5", params: []string{"5"}, match: true}, - {url: "/api/v1/15", params: []string{"15"}, match: false}, + {url: "/api/v1/15", params: nil, match: false}, }) benchCase("/api/v1/:param", []testparams{ - {url: "/api/v1/ent", params: []string{"ent"}, match: false}, + {url: "/api/v1/ent", params: nil, match: false}, {url: "/api/v1/9", params: []string{"9"}, match: true}, {url: "/api/v1/5", params: []string{"5"}, match: true}, - {url: "/api/v1/15", params: []string{"15"}, match: false}, + {url: "/api/v1/15", params: nil, match: false}, }) benchCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, - {url: "/api/v1/8728382", params: []string{"8728382"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, + {url: "/api/v1/8728382", params: nil, match: false}, {url: "/api/v1/2005-11-01", params: []string{"2005-11-01"}, match: true}, }) benchCase("/api/v1/:param", []testparams{ - {url: "/api/v1/ent", params: []string{"ent"}, match: false}, - {url: "/api/v1/15", params: []string{"15"}, match: false}, + {url: "/api/v1/ent", params: nil, match: false}, + {url: "/api/v1/15", params: nil, match: false}, {url: "/api/v1/peach", params: []string{"peach"}, match: true}, - {url: "/api/v1/p34ch", params: []string{"p34ch"}, match: false}, + {url: "/api/v1/p34ch", params: nil, match: false}, }) benchCase("/api/v1/:param", []testparams{ - {url: "/api/v1/ent", params: []string{"ent"}, match: false}, - {url: "/api/v1/15", params: []string{"15"}, match: false}, + {url: "/api/v1/ent", params: nil, match: false}, + {url: "/api/v1/15", params: nil, match: false}, {url: "/api/v1/2022-08-27", params: []string{"2022-08-27"}, match: true}, - {url: "/api/v1/2022/08-27", params: []string{"p34ch"}, match: false}, + {url: "/api/v1/2022/08-27", params: nil, match: false}, }) benchCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, {url: "/api/v1/8728382", params: []string{"8728382"}, match: true}, - {url: "/api/v1/true", params: []string{"true"}, match: false}, + {url: "/api/v1/true", params: nil, match: false}, }) benchCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, - {url: "/api/v1/8728382", params: []string{"8728382"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, + {url: "/api/v1/8728382", params: nil, match: false}, {url: "/api/v1/123", params: []string{"123"}, match: true}, - {url: "/api/v1/true", params: []string{"true"}, match: false}, + {url: "/api/v1/true", params: nil, match: false}, }) benchCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, - {url: "/api/v1/87283827683", params: []string{"8728382"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, + {url: "/api/v1/87283827683", params: nil, match: false}, {url: "/api/v1/123", params: []string{"123"}, match: true}, - {url: "/api/v1/true", params: []string{"true"}, match: false}, + {url: "/api/v1/true", params: nil, match: false}, }) benchCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, - {url: "/api/v1/87283827683", params: []string{"8728382"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, + {url: "/api/v1/87283827683", params: nil, match: false}, {url: "/api/v1/25", params: []string{"25"}, match: true}, - {url: "/api/v1/true", params: []string{"true"}, match: false}, + {url: "/api/v1/true", params: nil, match: false}, }) benchCase("/api/v1/:param", []testparams{ {url: "/api/v1/entity", params: []string{"entity"}, match: true}, @@ -787,10 +816,39 @@ func Benchmark_Path_matchParams(t *testing.B) { {url: "/api/v1/true", params: []string{"true"}, match: true}, }) benchCase("/api/v1/:param", []testparams{ - {url: "/api/v1/entity", params: []string{"entity"}, match: false}, - {url: "/api/v1/87283827683", params: []string{"8728382"}, match: false}, + {url: "/api/v1/entity", params: nil, match: false}, + {url: "/api/v1/87283827683", params: nil, match: false}, {url: "/api/v1/25", params: []string{"25"}, match: true}, {url: "/api/v1/1200", params: []string{"1200"}, match: true}, - {url: "/api/v1/true", params: []string{"true"}, match: false}, + {url: "/api/v1/true", params: nil, match: false}, + }) + benchCase("/api/v1/:lang/videos/:page", []testparams{ + {url: "/api/v1/try/videos/200", params: nil, match: false}, + {url: "/api/v1/tr/videos/1800", params: nil, match: false}, + {url: "/api/v1/tr/videos/100", params: []string{"tr", "100"}, match: true}, + {url: "/api/v1/e/videos/10", params: nil, match: false}, + }) + benchCase("/api/v1/:lang/:page", []testparams{ + {url: "/api/v1/try/200", params: nil, match: false}, + {url: "/api/v1/tr/1800", params: nil, match: false}, + {url: "/api/v1/tr/100", params: []string{"tr", "100"}, match: true}, + {url: "/api/v1/e/10", params: nil, match: false}, + }) + benchCase("/api/v1/:lang/:page", []testparams{ + {url: "/api/v1/try/200", params: []string{"try", "200"}, match: true}, + {url: "/api/v1/tr/1800", params: nil, match: false}, + {url: "/api/v1/tr/100", params: []string{"tr", "100"}, match: true}, + {url: "/api/v1/e/10", params: nil, match: false}, + }) + benchCase("/api/v1/:lang/:page", []testparams{ + {url: "/api/v1/try/200", params: nil, match: false}, + {url: "/api/v1/tr/1800", params: []string{"tr", "1800"}, match: true}, + {url: "/api/v1/tr/100", params: []string{"tr", "100"}, match: true}, + {url: "/api/v1/e/10", params: nil, match: false}, + }) + benchCase("/api/v1/:date/:regex", []testparams{ + {url: "/api/v1/2005-11-01/a", params: nil, match: false}, + {url: "/api/v1/2005-1101/paach", params: nil, match: false}, + {url: "/api/v1/2005-11-01/peach", params: []string{"2005-11-01", "peach"}, match: true}, }) }