mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-18 23:42:59 +00:00
always start redirect count at 1 when redirecting /hub/user/:name -> /user/:name
/hub/user/:name is now only reasonably visited as a result of redirect from /user/:name
This commit is contained in:
@@ -1575,7 +1575,6 @@ class UserUrlHandler(BaseHandler):
|
|||||||
if self.subdomain_host:
|
if self.subdomain_host:
|
||||||
target = user.host + target
|
target = user.host + target
|
||||||
|
|
||||||
referer = self.request.headers.get('Referer', '')
|
|
||||||
# record redirect count in query parameter
|
# record redirect count in query parameter
|
||||||
if redirects:
|
if redirects:
|
||||||
self.log.warning("Redirect loop detected on %s", self.request.uri)
|
self.log.warning("Redirect loop detected on %s", self.request.uri)
|
||||||
@@ -1587,8 +1586,12 @@ class UserUrlHandler(BaseHandler):
|
|||||||
query_parts['redirects'] = redirects + 1
|
query_parts['redirects'] = redirects + 1
|
||||||
url_parts = url_parts._replace(query=urlencode(query_parts, doseq=True))
|
url_parts = url_parts._replace(query=urlencode(query_parts, doseq=True))
|
||||||
target = urlunparse(url_parts)
|
target = urlunparse(url_parts)
|
||||||
elif '/user/{}'.format(user.name) in referer or not referer:
|
else:
|
||||||
# add first counter only if it's a redirect from /user/:name -> /hub/user/:name
|
# Start redirect counter.
|
||||||
|
# This should only occur for redirects from /user/:name -> /hub/user/:name
|
||||||
|
# when the corresponding server is already ready.
|
||||||
|
# We don't check this explicitly (direct visits to /hub/user are technically possible),
|
||||||
|
# but that's now the only normal way to get here.
|
||||||
target = url_concat(target, {'redirects': 1})
|
target = url_concat(target, {'redirects': 1})
|
||||||
|
|
||||||
self.redirect(target)
|
self.redirect(target)
|
||||||
|
Reference in New Issue
Block a user