# HG changeset patch # User Goffi # Date 1516826769 -3600 # Node ID 3f6f4d907c30a5b5d4ee2c2cf7b84043fa7174e8 # Parent 614843c49d6c7de4e7e5b7fe94a84bfc751e77f2 server: better redirection (fixed issue in remaining path arguments) diff -r 614843c49d6c -r 3f6f4d907c30 src/server/server.py --- a/src/server/server.py Wed Jan 24 21:44:26 2018 +0100 +++ b/src/server/server.py Wed Jan 24 21:46:09 2018 +0100 @@ -352,18 +352,12 @@ if isinstance(resource, web_resource.NoResource): # if nothing was found, we try our luck with redirections # XXX: we want redirections to happen only if everything else failed - - # first we check with current URL - # there our last try with the remaining URL - for path_elts in (request.prepath, - [name] + request.postpath): - current_url = '/'.join(path_elts).lower() - try: - request_data = self.redirections[current_url] - except KeyError: - # no redirection for this url - pass - else: + path_elt = request.prepath + request.postpath + for idx in xrange(len(path_elt), 0, -1): + test_url = '/'.join(path_elt[:idx]).lower() + if test_url in self.redirections: + request_data = self.redirections[test_url] + request.postpath = path_elt[idx:] return self._redirect(request, request_data) return resource