summaryrefslogtreecommitdiff
path: root/addons/http_routing/models
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2019-03-25 12:05:24 +0000
committerNicolas Lempereur <nle@odoo.com>2019-04-02 14:45:24 +0000
commit8557bcfa302de7aca4b5dadb35841cd52f9ebfff (patch)
treef05d8ab6540354fa8bc6b054c77b6aca81b62205 /addons/http_routing/models
parentf1744a31a1fa3494345f9502bfd6cb5b8aa95ffa (diff)
[FIX] website: language prefixed URL on website bis
Reintroduces 5324284f5 that was reverted because in the case of an URL like /payment_stripe/static/src/js/stripe.js directly inside a QWeb template, we would possibly get: /fr_FR/payment_stripe/static/src/js/stripe.js Which is not accepted by werkzeug SharedDataMiddleware we use to serve static data in /{module_name}/static/ directories. Added test without changeset failed with: - test_process_att_no_request_lang: <AssertionError> line: self._test_att('/en_US/', {'href': '/'}) wrong result: {'href': '/en_US/'} - test_process_att_with_request_lang: <AssertionError> line: self._test_att('/', {'href': '/fr_FR/'}) wrong result: {'href': '/'} - test_process_att_matching_cdn_and_lang: <AssertionError> line: self._test_att('/en_US/a', {'href': 'http://test.cdn/a'}) wrong result: {'href': 'http://test.cdn/en_US/a'} - test_process_att_no_route: <AssertionError> line: self._test_att('/my-page', {'href': '/fr_FR/my-page'}) wrong result: {'href': '/my-page'} - test_process_att_url_crap: <IndexError: list index out of range> line: request.httprequest.app._log_call[-1], opw-1922051 closes #32095 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Diffstat (limited to 'addons/http_routing/models')
-rw-r--r--addons/http_routing/models/ir_http.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/addons/http_routing/models/ir_http.py b/addons/http_routing/models/ir_http.py
index 0129bc90e6d..3388aabeb80 100644
--- a/addons/http_routing/models/ir_http.py
+++ b/addons/http_routing/models/ir_http.py
@@ -164,7 +164,7 @@ def is_multilang_url(local_url, langs=None):
local_url = '/'.join(spath)
try:
# Try to match an endpoint in werkzeug's routing table
- url = local_url.split('?')
+ url = local_url.partition('#')[0].split('?')
path = url[0]
query_string = url[1] if len(url) > 1 else None
router = request.httprequest.app.get_db_router(request.db).bind('')
@@ -173,6 +173,10 @@ def is_multilang_url(local_url, langs=None):
return (func.routing.get('website', False) and
func.routing.get('multilang', func.routing['type'] == 'http'))
except werkzeug.exceptions.NotFound:
+ # Consider /static/ files as non-multilang
+ static_index = path.find('/static/', 1)
+ if static_index != -1 and static_index == path.find('/', 1):
+ return False
return True
except Exception as e:
return False