@@ -523,19 +523,24 @@ TEST_F(PathMatcherTest, CustomVerbMatches) {
523
523
}
524
524
525
525
TEST_F (PathMatcherTest, CustomVerbMatch2) {
526
- MethodInfo* verb = AddGetPath (" /*/* :verb" );
526
+ MethodInfo* verb = AddGetPath (" /{a=*}/{b=*} :verb" );
527
527
Build ();
528
- EXPECT_EQ (LookupNoBindings (" GET" , " /some:verb/const:verb" ), verb);
528
+ Bindings bindings;
529
+ EXPECT_EQ (Lookup (" GET" , " /some:verb/const:verb" , &bindings), verb);
530
+ EXPECT_EQ (bindings.size (), 2 );
531
+ EXPECT_EQ (bindings[0 ].value , " some:verb" );
532
+ EXPECT_EQ (bindings[1 ].value , " const" );
529
533
}
530
534
531
535
TEST_F (PathMatcherTest, CustomVerbMatch3) {
532
- EXPECT_NE ( nullptr , AddGetPath (" /foo/* " ) );
536
+ MethodInfo* verb = AddGetPath (" /foo/{a=*} " );
533
537
Build ();
534
538
535
- // This should match. But due to an implementation bug which
536
- // blinkdly replacing last : with /, it will use /foo/other/verb
537
- // to match /foo/* which will fail.
538
- EXPECT_EQ (LookupNoBindings (" GET" , " /foo/other:verb" ), nullptr );
539
+ // This is not custom verb since it was not configured.
540
+ Bindings bindings;
541
+ EXPECT_EQ (Lookup (" GET" , " /foo/other:verb" , &bindings), verb);
542
+ EXPECT_EQ (bindings.size (), 1 );
543
+ EXPECT_EQ (bindings[0 ].value , " other:verb" );
539
544
}
540
545
541
546
TEST_F (PathMatcherTest, CustomVerbMatch4) {
@@ -548,6 +553,24 @@ TEST_F(PathMatcherTest, CustomVerbMatch4) {
548
553
EXPECT_EQ (LookupNoBindings (" GET" , " /foo/other:verb/hello" ), a);
549
554
}
550
555
556
+ TEST_F (PathMatcherTest, CustomVerbMatch5) {
557
+ MethodInfo* verb = AddGetPath (" /{a=**}:verb" );
558
+ MethodInfo* non_verb = AddGetPath (" /{a=**}" );
559
+ Build ();
560
+ Bindings bindings;
561
+ EXPECT_EQ (Lookup (" GET" , " /some:verb/const:verb" , &bindings), verb);
562
+ EXPECT_EQ (bindings.size (), 1 );
563
+ EXPECT_EQ (bindings[0 ].value , " some:verb/const" );
564
+ bindings.clear ();
565
+ EXPECT_EQ (Lookup (" GET" , " /some:verb/const" , &bindings), non_verb);
566
+ EXPECT_EQ (bindings.size (), 1 );
567
+ EXPECT_EQ (bindings[0 ].value , " some:verb/const" );
568
+ bindings.clear ();
569
+ EXPECT_EQ (Lookup (" GET" , " /some:verb2/const:verb2" , &bindings), non_verb);
570
+ EXPECT_EQ (bindings.size (), 1 );
571
+ EXPECT_EQ (bindings[0 ].value , " some:verb2/const:verb2" );
572
+ }
573
+
551
574
TEST_F (PathMatcherTest, RejectPartialMatches) {
552
575
MethodInfo* prefix_middle_suffix = AddGetPath (" /prefix/middle/suffix" );
553
576
MethodInfo* prefix_middle = AddGetPath (" /prefix/middle" );
0 commit comments