Skip to content

Commit

Permalink
Merge pull request #592 from Paranaix/fix_pattern
Browse files Browse the repository at this point in the history
Strengthed uri Pattern tests and fixed parsing edge case
  • Loading branch information
Tobias Oberstein committed Feb 4, 2016
2 parents 29b10fd + 5a9e7f8 commit ca65b1f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions autobahn/wamp/test/test_uri_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def test_valid_uris(self):
for u in [u"com.myapp.proc1",
u"123",
u"com.myapp.<product:int>.update",
u"com.myapp.<category:string>.<subcategory>.list"
]:
p = Pattern(u, Pattern.URI_TARGET_ENDPOINT)
self.assertIsInstance(p, Pattern)
Expand All @@ -67,6 +68,19 @@ def test_parse_uris(self):
(u"com.myapp.123456.update", {u'product': u'123456'}),
(u"com.myapp..update", None),
]
),
(u"com.myapp.<product>.update", [
(u"com.myapp.0.update", {u'product': u'0'}),
(u"com.myapp.abc.update", {u'product': u'abc'}),
(u"com.myapp..update", None),
]
),
(u"com.myapp.<category:string>.<subcategory:string>.list", [
(u"com.myapp.cosmetic.shampoo.list", {u'category': u'cosmetic', u'subcategory': u'shampoo'}),
(u"com.myapp...list", None),
(u"com.myapp.cosmetic..list", None),
(u"com.myapp..shampoo.list", None),
]
)
]
for test in tests:
Expand Down
2 changes: 1 addition & 1 deletion autobahn/wamp/uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def __init__(self, uri, target):
raise Exception("invalid URI")

nc[name] = str
pl.append("(?P<{0}>[a-z][a-z0-9_]*)".format(name))
pl.append("(?P<{0}>[a-z0-9_]+)".format(name))
continue

match = Pattern._URI_COMPONENT.match(component)
Expand Down

0 comments on commit ca65b1f

Please sign in to comment.