# HG changeset patch # User Ludovic Chabant # Date 1437714719 25200 # Node ID 4284c673bb91d907010ba4dc80e2af6dd5494dbf # Parent 2537fe95d771f9e5514f6822af2e56da5a1eefcb internal: Fix some edge-cases for splitting sub-URIs. A given URI may or may not have a trailing slash, regardless of the `trailing_slash` configuration setting. Add unit tests to check those cases. diff -r 2537fe95d771 -r 4284c673bb91 piecrust/uriutil.py --- a/piecrust/uriutil.py Thu Jul 23 22:09:00 2015 -0700 +++ b/piecrust/uriutil.py Thu Jul 23 22:11:59 2015 -0700 @@ -92,7 +92,7 @@ trailing_slash = app.config.get('site/trailing_slash') if not pretty_urls: uri, ext = os.path.splitext(uri) - elif trailing_slash: + else: uri = uri.rstrip('/') page_num = 1 diff -r 2537fe95d771 -r 4284c673bb91 tests/test_uriutil.py --- a/tests/test_uriutil.py Thu Jul 23 22:09:00 2015 -0700 +++ b/tests/test_uriutil.py Thu Jul 23 22:11:59 2015 -0700 @@ -30,7 +30,8 @@ ('/', ('/', 1), True), ('/2', ('/', 2), True), ('/foo/bar', ('/foo/bar', 1), True), - ('/foo/bar/2', ('/foo/bar', 2), True), + ('/foo/bar/', ('/foo/bar', 1), True), + ('/foo/bar/2/', ('/foo/bar', 2), True), ('/foo/bar.ext', ('/foo/bar.ext', 1), True), ('/foo/bar.ext/2', ('/foo/bar.ext', 2), True), ('/', ('/', 1), False), @@ -53,7 +54,9 @@ @pytest.mark.parametrize('uri, expected, pretty_urls', [ ('/', ('/', 1), True), ('/2/', ('/', 2), True), + ('/foo/bar', ('/foo/bar/', 1), True), ('/foo/bar/', ('/foo/bar/', 1), True), + ('/foo/bar/2', ('/foo/bar/', 2), True), ('/foo/bar/2/', ('/foo/bar/', 2), True), ('/foo/bar.ext/', ('/foo/bar.ext/', 1), True), ('/foo/bar.ext/2/', ('/foo/bar.ext/', 2), True), @@ -73,7 +76,9 @@ ('/', ('/', 1), True), ('/2', ('/', 2), True), ('/foo/bar', ('/foo/bar', 1), True), + ('/foo/bar/', ('/foo/bar', 1), True), ('/foo/bar/2', ('/foo/bar', 2), True), + ('/foo/bar/2/', ('/foo/bar', 2), True), ('/foo/bar.ext', ('/foo/bar.ext', 1), True), ('/foo/bar.ext/2', ('/foo/bar.ext', 2), True), ('/', ('/', 1), False),