-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
projects: serve badge with same protocol as site #4228
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this change. Essentially if the public domain supports HTTPS then we use it.
I like this change. Thanks! Could you write a test for this, please? There are other similar tests in the |
@humitos let's make a deal, you hook some coverage to the CI and I'll write tests if the code i am touching is not tested :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a helpful change! Public and production domain shouldn't be conflated though.
Echoing the need for tests also.
readthedocs/projects/views/public.py
Outdated
@@ -90,7 +90,8 @@ def get_context_data(self, **kwargs): | |||
user=self.request.user, project=project) | |||
|
|||
protocol = 'http' | |||
if self.request.is_secure(): | |||
use_https = getattr(settings, 'PUBLIC_DOMAIN_USES_HTTPS', False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this purpose, public domain != production domain. Badges are served from our production domain, docs are served from our public domain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what about removing the scheme altogether?
Instead of request.is_secure use a schemaless url for the badge url in project detail view.
I've pushed the schema-less version |
This looks like a much better fix. I like protocol relative URL's 👍 |
Without a protocol users can't copy/paste the badge generated code anymore #4337 |
Feel free to revert then until we found a solution that work. |
Instead of request.is_secure use settings.PUBLIC_DOMAIN_USES_HTTPS
to find out if we should serve the badge under https or not.
That matches what the resolver is doing and works here.