Remove trailing question-mark
This commit is contained in:
parent
6b53c42f14
commit
9a8166a39e
2 changed files with 21 additions and 2 deletions
|
@ -274,7 +274,13 @@ class BaseListingPage(RoutablePageMixin, BaseContentPage):
|
|||
query_data = self.serializer.validated_data.copy()
|
||||
if query_data["page"] == 1:
|
||||
del query_data["page"]
|
||||
return super().get_meta_url() + "?" + urlencode(query_data)
|
||||
|
||||
url = super().get_meta_url()
|
||||
|
||||
if not query_data:
|
||||
return url
|
||||
|
||||
return url + "?" + urlencode(query_data)
|
||||
|
||||
@route(r"^feed/$")
|
||||
@method_decorator(cache_page(60 * 30))
|
||||
|
|
|
@ -2,7 +2,7 @@ from django.template.loader import get_template
|
|||
from django.test import SimpleTestCase, TestCase
|
||||
|
||||
from website.common.factories import ContentPageFactory, ListingPageFactory
|
||||
from website.common.models import BasePage
|
||||
from website.common.models import BaseListingPage, BasePage
|
||||
from website.common.utils import get_page_models
|
||||
from website.home.models import HomePage
|
||||
|
||||
|
@ -66,3 +66,16 @@ class ListingPageTestCase(TestCase):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response["Content-Type"], "application/xml")
|
||||
self.assertContains(response, "xml-stylesheet")
|
||||
|
||||
def test_meta_url(self) -> None:
|
||||
response = self.client.get(self.page.url)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.context["page"].get_meta_url(), self.page.full_url)
|
||||
|
||||
def test_meta_url_with_page(self) -> None:
|
||||
ContentPageFactory.create_batch(BaseListingPage.PAGE_SIZE, parent=self.page)
|
||||
response = self.client.get(self.page.url, {"page": 2})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(
|
||||
response.context["page"].get_meta_url(), self.page.full_url + "?page=2"
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue