This is an automated email from the ASF dual-hosted git repository. brondsem pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/allura.git
commit e1e38fa7a2b270a429558c161ec582f962f56369 Author: Dave Brondsema <dbronds...@slashdotmedia.com> AuthorDate: Tue Jul 26 17:44:11 2022 +0000 [#8444] paginator links back to page=0 don't actually need page=0 in url since its default --- Allura/allura/lib/widgets/form_fields.py | 2 ++ ForgeWiki/forgewiki/tests/functional/test_root.py | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Allura/allura/lib/widgets/form_fields.py b/Allura/allura/lib/widgets/form_fields.py index 7d51cb446..c1a73d30a 100644 --- a/Allura/allura/lib/widgets/form_fields.py +++ b/Allura/allura/lib/widgets/form_fields.py @@ -309,6 +309,8 @@ class PageList(ew_core.Widget): def page_url(page): params = request.GET.copy() params['page'] = page - page_offset + if params['page'] == 0: + del params['page'] # REQUEST_URI keeps double-slashes, but not available in all environments (like tests) curr_path = urlparse(request.environ.get('REQUEST_URI')).path or request.path return url(curr_path, params) diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py index 67e473d50..0c4ea7f0f 100644 --- a/ForgeWiki/forgewiki/tests/functional/test_root.py +++ b/ForgeWiki/forgewiki/tests/functional/test_root.py @@ -477,16 +477,21 @@ class TestRootController(TestController): assert '(Page 1 of 4)' in r assert '<td>label30</td>' in r assert '<td>label1</td>' in r + r = self.app.get('/wiki/browse_tags/?page=2') + # back to first page (page 0) doesn't need page=0 in url: + assert '<a href="/wiki/browse_tags/">' in r + assert '<a href="/wiki/browse_tags/?page=0">' not in r assert '<td>label69</td>' in r assert '<td>label70</td>' in r r.mustcontain('canonical') canonical = r.html.select_one('link[rel=canonical]') assert 'browse_tags' in canonical['href'] next = r.html.select_one('link[rel=next]') - assert('page=3' in next['href']) + assert 'page=3' in next['href'] prev = r.html.select_one('link[rel=prev]') - assert('page=1' in prev['href']) + assert 'page=1' in prev['href'] + r = self.app.get('/wiki/browse_tags/?page=0') canonical = r.html.select_one('link[rel=canonical]') assert 'page=' not in canonical