Commit d943154f authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

fixup! ERP5Web: redirect to the minimum URL if verbose languages exist in URL.

so that we keep the query string in the redirect url if exists.
parent 3e9c87c3
...@@ -182,6 +182,9 @@ class WebSite(WebSection): ...@@ -182,6 +182,9 @@ class WebSite(WebSection):
redirect_path_list.append(name) redirect_path_list.append(name)
redirect_path_list.extend(reversed(request['TraversalRequestNameStack'])) redirect_path_list.extend(reversed(request['TraversalRequestNameStack']))
request['minimum_language_redirect_url'] = '/'.join(redirect_path_list) request['minimum_language_redirect_url'] = '/'.join(redirect_path_list)
query_string = request.get('QUERY_STRING')
if query_string:
request['minimum_language_redirect_url'] += '?' + query_string
return self.getOriginalDocument().asContext(id=name) return self.getOriginalDocument().asContext(id=name)
return WebSection.getExtensibleContent(self, request, name) return WebSection.getExtensibleContent(self, request, name)
......
...@@ -979,6 +979,8 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -979,6 +979,8 @@ Hé Hé Hé!""", page.asText().strip())
websection_fr.absolute_url()) websection_fr.absolute_url())
self.assertEqual(self.publish(webpage_bg_en_fr.absolute_url(relative=1)).getHeader('location'), self.assertEqual(self.publish(webpage_bg_en_fr.absolute_url(relative=1)).getHeader('location'),
webpage_fr.absolute_url()) webpage_fr.absolute_url())
self.assertEqual(self.publish(website_bg_en_fr.absolute_url(relative=1)+'?a=b&c=d').getHeader('location'),
website_fr.absolute_url()+'?a=b&c=d')
# /bg/en/xxx should be redirected to /xxx where en is the default language # /bg/en/xxx should be redirected to /xxx where en is the default language
website_bg_en = self.portal.restrictedTraverse( website_bg_en = self.portal.restrictedTraverse(
...@@ -993,6 +995,8 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -993,6 +995,8 @@ Hé Hé Hé!""", page.asText().strip())
websection.absolute_url()) websection.absolute_url())
self.assertEqual(self.publish(webpage_bg_en.absolute_url(relative=1)).getHeader('location'), self.assertEqual(self.publish(webpage_bg_en.absolute_url(relative=1)).getHeader('location'),
webpage.absolute_url()) webpage.absolute_url())
self.assertEqual(self.publish(websection_bg_en.absolute_url(relative=1)+'?a=b&c=d').getHeader('location'),
websection.absolute_url()+'?a=b&c=d')
# /en/xxx should be redirected to /xxx where en is the default language # /en/xxx should be redirected to /xxx where en is the default language
website_en = self.portal.restrictedTraverse( website_en = self.portal.restrictedTraverse(
...@@ -1007,6 +1011,8 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -1007,6 +1011,8 @@ Hé Hé Hé!""", page.asText().strip())
websection.absolute_url()) websection.absolute_url())
self.assertEqual(self.publish(webpage_en.absolute_url(relative=1)).getHeader('location'), self.assertEqual(self.publish(webpage_en.absolute_url(relative=1)).getHeader('location'),
webpage.absolute_url()) webpage.absolute_url())
self.assertEqual(self.publish(webpage_en.absolute_url(relative=1)+'?a=b&c=d').getHeader('location'),
webpage.absolute_url()+'?a=b&c=d')
def test_13_DocumentCache(self): def test_13_DocumentCache(self):
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment