From 5037210c24cb08c74ff671a755b24964afb9097b Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 28 Aug 2018 20:10:52 +0200 Subject: [PATCH] Always use HTTPS protocol when require_https_domain is True --- readthedocs/core/resolver.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/readthedocs/core/resolver.py b/readthedocs/core/resolver.py index abe1d5d9671..46ebff2d16a 100644 --- a/readthedocs/core/resolver.py +++ b/readthedocs/core/resolver.py @@ -161,10 +161,13 @@ def resolve(self, project, require_https_domain=False, filename='', private=None domain = getattr(settings, 'PRODUCTION_DOMAIN') protocol = 'http' - if custom_domain: - # Rely on the ``Domain.https`` field or force it if specified - if custom_domain.https or require_https_domain: - protocol = 'https' + # Rely on the ``Domain.https`` field or force it if specified + use_https_protocol = any([ + (custom_domain and custom_domain.https), + require_https_domain, + ]) + if use_https_protocol: + protocol = 'https' else: # Use HTTPS if settings specify public_domain = getattr(settings, 'PUBLIC_DOMAIN', None)