Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1089 from alex-marandon/develop

Fix 404 when APPEND_SLASH set to False
  • Loading branch information...
commit 8cace6b2d4385929a4dda73939743816c82a9606 2 parents 1aa8ab0 + 736529e
@ojii ojii authored
Showing with 16 additions and 2 deletions.
  1. +11 −0 cms/tests/page.py
  2. +5 −2 cms/utils/page_resolver.py
View
11 cms/tests/page.py
@@ -409,6 +409,17 @@ def test_get_page_from_request_with_page_404(self):
request = self.get_request('/does-not-exist/')
found_page = get_page_from_request(request)
self.assertEqual(found_page, None)
+
+ def test_get_page_without_final_slash(self):
+ root = create_page("root", "nav_playground.html", "en", slug="root",
+ published=True)
+ page = create_page("page", "nav_playground.html", "en", slug="page",
+ published=True, parent=root)
+ root.publish()
+ page.publish()
+ request = self.get_request('/page')
+ found_page = get_page_from_request(request)
+ self.assertFalse(found_page is None)
def test_get_page_from_request_with_page_preview(self):
page = create_page("page", "nav_playground.html", "en")
View
7 cms/utils/page_resolver.py
@@ -101,8 +101,11 @@ def get_page_from_request(request, use_path=None):
if use_path:
path = use_path
else:
- # otherwise strip of the non-cms part of the URL
- path = request.path[len(pages_root):-1]
+ # otherwise strip off the non-cms part of the URL
+ path = request.path[len(pages_root):]
+ # and strip any final slash
+ if path.endswith("/"):
+ path = path[:-1]
page = get_page_from_path(path, preview)
Please sign in to comment.
Something went wrong with that request. Please try again.