Skip to content

Commit

Permalink
Fixed shortener key matching above final '*' level.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmorell committed May 17, 2024
1 parent 96bb8eb commit 7ece3cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 3 additions & 5 deletions rollbar/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,16 @@ def key_depth(key, canonicals) -> int:


def key_match(key, canonical):
i = 0
if len(key) < len(canonical):
return False

for k, c in zip(key, canonical):
i += 1
if '*' == c:
continue
if c == k:
continue
return False

if i < len(canonical) - 1:
return False

return True


Expand Down
6 changes: 6 additions & 0 deletions rollbar/test/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ def test_key_match_wildcard_end(self):

self.assertTrue(key_match(key, canonical))

def test_key_match_too_short(self):
canonical = ['body', 'trace', 'frames', '*', 'locals', '*']
key = ['body', 'trace', 'frames', 5, 'locals']

self.assertFalse(key_match(key, canonical))

def test_key_depth(self):
canonicals = [['body', 'trace', 'frames', '*', 'locals', '*']]
key = ['body', 'trace', 'frames', 5, 'locals', 'foo']
Expand Down

0 comments on commit 7ece3cb

Please sign in to comment.