File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -240,8 +240,8 @@ def handlers_for_address(
240240 matched = False
241241 for addr , handlers in self ._map .items ():
242242 if patterncompiled .match (addr ) or (
243- ( "*" in addr )
244- and re .match (addr .replace ("*" , "[^/]*?/*" ) , address_pattern )
243+ "*" in addr
244+ and re .match (addr .replace ("*" , ".*?" ) + "$" , address_pattern )
245245 ):
246246 yield from handlers
247247 matched = True
Original file line number Diff line number Diff line change @@ -181,6 +181,17 @@ def dummyhandler():
181181 with self .assertRaises (ValueError ):
182182 self .dispatcher .unmap ("/unmap/exception" , handlerobj )
183183
184+ def test_handlers_for_address_wildcard_no_partial_match (self ):
185+ self .dispatcher .map ("/qwer/*/zxcv" , 1 )
186+ # Should not match
187+ handlers = list (
188+ self .dispatcher .handlers_for_address ("/qwer/whatever/zxcvsomethingmore" )
189+ )
190+ self .assertEqual (len (handlers ), 0 )
191+ # Should match
192+ handlers = list (self .dispatcher .handlers_for_address ("/qwer/whatever/zxcv" ))
193+ self .assertEqual (len (handlers ), 1 )
194+
184195
185196if __name__ == "__main__" :
186197 unittest .main ()
You can’t perform that action at this time.
0 commit comments