Mercurial > libervia-web
comparison libervia/server/pages.py @ 1476:c669b5bfb8a0
pages: fix args range in `getURL` + use `urljoin`:
`urljoin` is used to have more adapter `/` management, and avoid a trailing one
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 20 Oct 2021 17:17:21 +0200 |
parents | b4cead3cea43 |
children | 095e94ca6728 |
comparison
equal
deleted
inserted
replaced
1475:83cd4862b134 | 1476:c669b5bfb8a0 |
---|---|
680 | 680 |
681 if self.name is not None and self.name in self.pages_redirects: | 681 if self.name is not None and self.name in self.pages_redirects: |
682 # we check for redirection | 682 # we check for redirection |
683 redirect_data = self.pages_redirects[self.name] | 683 redirect_data = self.pages_redirects[self.name] |
684 args_hash = tuple(args) | 684 args_hash = tuple(args) |
685 for limit in range(len(args) + 1): | 685 for limit in range(len(args), -1, -1): |
686 current_hash = args_hash[:limit] | 686 current_hash = args_hash[:limit] |
687 if current_hash in redirect_data: | 687 if current_hash in redirect_data: |
688 url_base = redirect_data[current_hash] | 688 url_base = redirect_data[current_hash] |
689 remaining = args[limit:] | 689 remaining = args[limit:] |
690 remaining_url = "/".join(remaining) | 690 remaining_url = "/".join(remaining) |
691 url = os.path.join("/", url_base, remaining_url) | 691 url = urllib.parse.urljoin(url_base, remaining_url) |
692 break | 692 break |
693 else: | 693 else: |
694 url = os.path.join(self.url, *url_args) | 694 url = os.path.join(self.url, *url_args) |
695 else: | 695 else: |
696 url = os.path.join(self.url, *url_args) | 696 url = os.path.join(self.url, *url_args) |