@@ -523,19 +523,24 @@ TEST_F(PathMatcherTest, CustomVerbMatches) {
523523}
524524
525525TEST_F (PathMatcherTest, CustomVerbMatch2) {
526- MethodInfo* verb = AddGetPath (" /*/* :verb" );
526+ MethodInfo* verb = AddGetPath (" /{a=*}/{b=*} :verb" );
527527 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" );
529533}
530534
531535TEST_F (PathMatcherTest, CustomVerbMatch3) {
532- EXPECT_NE ( nullptr , AddGetPath (" /foo/* " ) );
536+ MethodInfo* verb = AddGetPath (" /foo/{a=*} " );
533537 Build ();
534538
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" );
539544}
540545
541546TEST_F (PathMatcherTest, CustomVerbMatch4) {
@@ -548,6 +553,24 @@ TEST_F(PathMatcherTest, CustomVerbMatch4) {
548553 EXPECT_EQ (LookupNoBindings (" GET" , " /foo/other:verb/hello" ), a);
549554}
550555
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+
551574TEST_F (PathMatcherTest, RejectPartialMatches) {
552575 MethodInfo* prefix_middle_suffix = AddGetPath (" /prefix/middle/suffix" );
553576 MethodInfo* prefix_middle = AddGetPath (" /prefix/middle" );
0 commit comments