Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14f2c9d345 | ||
|
|
d0a4cf8fa7 | ||
|
|
901f4e55b8 |
@@ -1,5 +1,9 @@
|
|||||||
# Microdot change log
|
# Microdot change log
|
||||||
|
|
||||||
|
**Release 2.0.5** - 2024-03-09
|
||||||
|
|
||||||
|
- Correct handling of 0 as an integer argument (regression from #207) [#212](https://github.com/miguelgrinberg/microdot/issues/212) ([commit](https://github.com/miguelgrinberg/microdot/commit/d0a4cf8fa7dfb1da7466157b18d3329a8cf9a5df))
|
||||||
|
|
||||||
**Release 2.0.4** - 2024-02-20
|
**Release 2.0.4** - 2024-02-20
|
||||||
|
|
||||||
- Do not use regexes for parsing simple URLs [#207](https://github.com/miguelgrinberg/microdot/issues/207) ([commit #1](https://github.com/miguelgrinberg/microdot/commit/38262c56d34784401659639b482a4a1224e1e59a) [commit #2](https://github.com/miguelgrinberg/microdot/commit/f6cba2c0f7e18e2f32b5adb779fb037b6c473eab))
|
- Do not use regexes for parsing simple URLs [#207](https://github.com/miguelgrinberg/microdot/issues/207) ([commit #1](https://github.com/miguelgrinberg/microdot/commit/38262c56d34784401659639b482a4a1224e1e59a) [commit #2](https://github.com/miguelgrinberg/microdot/commit/f6cba2c0f7e18e2f32b5adb779fb037b6c473eab))
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "microdot"
|
name = "microdot"
|
||||||
version = "2.0.4"
|
version = "2.0.5"
|
||||||
authors = [
|
authors = [
|
||||||
{ name = "Miguel Grinberg", email = "miguel.grinberg@gmail.com" },
|
{ name = "Miguel Grinberg", email = "miguel.grinberg@gmail.com" },
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -862,8 +862,6 @@ class URLPattern():
|
|||||||
if arg is None:
|
if arg is None:
|
||||||
return
|
return
|
||||||
if 'name' in segment:
|
if 'name' in segment:
|
||||||
if not arg:
|
|
||||||
return
|
|
||||||
args[segment['name']] = arg
|
args[segment['name']] = arg
|
||||||
if path is not None:
|
if path is not None:
|
||||||
return
|
return
|
||||||
@@ -879,6 +877,8 @@ class URLPattern():
|
|||||||
|
|
||||||
def _string_segment(self, value):
|
def _string_segment(self, value):
|
||||||
s = value.split('/', 1)
|
s = value.split('/', 1)
|
||||||
|
if len(s[0]) == 0:
|
||||||
|
return None, None
|
||||||
return s[0], s[1] if len(s) > 1 else None
|
return s[0], s[1] if len(s) > 1 else None
|
||||||
|
|
||||||
def _int_segment(self, value):
|
def _int_segment(self, value):
|
||||||
|
|||||||
@@ -26,10 +26,14 @@ class TestURLPattern(unittest.TestCase):
|
|||||||
p = URLPattern('/<arg>')
|
p = URLPattern('/<arg>')
|
||||||
self.assertEqual(p.match('/foo'), {'arg': 'foo'})
|
self.assertEqual(p.match('/foo'), {'arg': 'foo'})
|
||||||
self.assertIsNone(p.match('/'))
|
self.assertIsNone(p.match('/'))
|
||||||
|
self.assertIsNone(p.match('//'))
|
||||||
self.assertIsNone(p.match(''))
|
self.assertIsNone(p.match(''))
|
||||||
self.assertIsNone(p.match('foo/'))
|
self.assertIsNone(p.match('foo/'))
|
||||||
self.assertIsNone(p.match('/foo/'))
|
self.assertIsNone(p.match('/foo/'))
|
||||||
|
self.assertIsNone(p.match('//foo/'))
|
||||||
|
self.assertIsNone(p.match('/foo//'))
|
||||||
self.assertIsNone(p.match('/foo/bar'))
|
self.assertIsNone(p.match('/foo/bar'))
|
||||||
|
self.assertIsNone(p.match('/foo//bar'))
|
||||||
|
|
||||||
p = URLPattern('/<arg>/')
|
p = URLPattern('/<arg>/')
|
||||||
self.assertEqual(p.match('/foo/'), {'arg': 'foo'})
|
self.assertEqual(p.match('/foo/'), {'arg': 'foo'})
|
||||||
@@ -64,6 +68,8 @@ class TestURLPattern(unittest.TestCase):
|
|||||||
def test_int_argument(self):
|
def test_int_argument(self):
|
||||||
p = URLPattern('/users/<int:id>')
|
p = URLPattern('/users/<int:id>')
|
||||||
self.assertEqual(p.match('/users/123'), {'id': 123})
|
self.assertEqual(p.match('/users/123'), {'id': 123})
|
||||||
|
self.assertEqual(p.match('/users/-123'), {'id': -123})
|
||||||
|
self.assertEqual(p.match('/users/0'), {'id': 0})
|
||||||
self.assertIsNone(p.match('/users/'))
|
self.assertIsNone(p.match('/users/'))
|
||||||
self.assertIsNone(p.match('/users/abc'))
|
self.assertIsNone(p.match('/users/abc'))
|
||||||
self.assertIsNone(p.match('/users/123abc'))
|
self.assertIsNone(p.match('/users/123abc'))
|
||||||
|
|||||||
Reference in New Issue
Block a user