File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,9 @@ const (
1717 // TerminationCharacter is a special character for end of path.
1818 TerminationCharacter = '#'
1919
20+ // SeparatorCharacter separates path segments.
21+ SeparatorCharacter = '/'
22+
2023 // MaxSize is max size of records and internal slice.
2124 MaxSize = (1 << 22 ) - 1
2225)
@@ -420,10 +423,11 @@ type record struct {
420423
421424// makeRecords returns the records that use to build Double-Arrays.
422425func makeRecords (srcs []Record ) (statics , params []* record ) {
423- spChars := string ([]byte {ParamCharacter , WildcardCharacter })
424426 termChar := string (TerminationCharacter )
427+ paramPrefix := string (SeparatorCharacter ) + string (ParamCharacter )
428+ wildcardPrefix := string (SeparatorCharacter ) + string (WildcardCharacter )
425429 for _ , r := range srcs {
426- if strings .ContainsAny (r .Key , spChars ) {
430+ if strings .Contains (r .Key , paramPrefix ) || strings . Contains ( r . Key , wildcardPrefix ) {
427431 r .Key += termChar
428432 params = append (params , & record {Record : r })
429433 } else {
Original file line number Diff line number Diff line change @@ -448,6 +448,7 @@ func TestRouter_Build_withoutSizeHint(t *testing.T) {
448448 {[]string {"/user" }, 0 },
449449 {[]string {"/user/:id" }, 1 },
450450 {[]string {"/user/:id/post" }, 1 },
451+ {[]string {"/user/:id/post:validate" }, 2 },
451452 {[]string {"/user/:id/:group" }, 2 },
452453 {[]string {"/user/:id/post/:cid" }, 2 },
453454 {[]string {"/user/:id/post/:cid" , "/admin/:id/post/:cid" }, 2 },
@@ -487,6 +488,7 @@ func TestRouter_Build_withSizeHint(t *testing.T) {
487488 {"/user/:id" , 3 , 3 },
488489 {"/user/:id/:group" , 0 , 0 },
489490 {"/user/:id/:group" , 1 , 1 },
491+ {"/user/:id/:group:validate" , 1 , 1 },
490492 } {
491493 r := denco .New ()
492494 r .SizeHint = v .sizeHint
You can’t perform that action at this time.
0 commit comments