add_sr: allow alternate domains for https pages

`add_sr()` has had, since reddit/reddit@b57dff70, a special-case when the
requested page was on https, where it would ignore whatever domain it would
normally set and use the current one instead.  As best as we can tell, this was
to prevent issues with a lack of https support on all reddit domains, eg links
on `https://pay.reddit.com` pointing to `https://www.reddit.com`.  This should
no longer be an issue.

Additionally, it has caused problems with the comment embeds, which are served
from `redditmedia.com` but need to have links pointing to `www.reddit.com`.

Now that this special-case doesn't exist, the function should act more
intuitively.  And hopefully that doesn't break anything too badly. :p

The request from the comment embed javascript to get the actual embed has been
going through `g.media_domain`.  This in turn meant that sometimes (namely,
when the embed was placed on an https page) the link to the comment was also
heading through the media domain.  While this works, we'd rather have users go
through the standard `www.reddit.com` domain for brand, caching, and probably
other infrastructure reasons.
This commit is contained in:
xiongchiamiov
2015-01-14 14:20:13 -08:00
committed by David Wick
parent bf300d1ecc
commit e454857b31

View File

@@ -460,11 +460,8 @@ def add_sr(
u.path_add_subreddit(c.site)
if not u.hostname or force_hostname:
if c.secure:
u.hostname = request.host
else:
u.hostname = get_domain(cname = (c.cname and not nocname),
subreddit = False)
u.hostname = get_domain(cname = (c.cname and not nocname),
subreddit = False)
if (c.secure and u.is_reddit_url()) or force_https:
u.scheme = "https"