only start ?redirects counter if we are starting from a /user/:name -> /hub/user/:name redirect

This commit is contained in:
Min RK
2019-02-27 11:13:10 +01:00
parent fee81c7d33
commit 8ea5a957a6

View File

@@ -1377,6 +1377,7 @@ class UserUrlHandler(BaseHandler):
if self.subdomain_host:
target = user.host + target
referer = self.request.headers.get('Referer', '')
# record redirect count in query parameter
if redirects:
self.log.warning("Redirect loop detected on %s", self.request.uri)
@@ -1388,7 +1389,8 @@ class UserUrlHandler(BaseHandler):
query_parts['redirects'] = redirects + 1
url_parts = url_parts._replace(query=urlencode(query_parts, doseq=True))
target = urlunparse(url_parts)
else:
elif '/user/' in referer:
# add first counter only if it's a redirect from /user/:name -> /hub/user/:name
target = url_concat(target, {'redirects': 1})
self.redirect(target)