New force_https_urls option, refs #333

This commit is contained in:
Simon Willison 2018-07-23 08:58:29 -07:00
commit f24b49a1a8
No known key found for this signature in database
GPG key ID: 17E2DEA2588B7F52
5 changed files with 44 additions and 11 deletions

View file

@ -142,6 +142,12 @@ class BaseView(RenderMixin):
return name, expected, None
def absolute_url(self, request, path):
url = urllib.parse.urljoin(request.url, path)
if url.startswith("http://") and self.ds.config["force_https_urls"]:
url = "https://" + url[len("http://"):]
return url
def get_templates(self, database, table=None):
assert NotImplemented