comparison libervia/server/pages.py @ 1456:284522d8af44

pages: check redirections for LiberviaPage.getURL: rel 395
author Goffi <goffi@goffi.org>
date Wed, 29 Sep 2021 17:38:29 +0200
parents e8c480b0078e
children 2c8449885272
comparison
equal deleted inserted replaced
1455:e8c480b0078e 1456:284522d8af44
663 redirect_url=urllib.parse.quote_plus(request.uri) 663 redirect_url=urllib.parse.quote_plus(request.uri)
664 if url is None 664 if url is None
665 else url.encode("utf-8"), 665 else url.encode("utf-8"),
666 ) 666 )
667 667
668 def getURL(self, *args): 668 def getURL(self, *args: str) -> str:
669 """retrieve URL of the page set arguments 669 """retrieve URL of the page set arguments
670 670
671 *args(list[unicode]): argument to add to the URL as path elements 671 @param *args: arguments to add to the URL as path elements empty or None
672 empty or None arguments will be ignored 672 arguments will be ignored
673 """ 673 """
674 url_args = [quote(a) for a in args if a] 674 url_args = [quote(a) for a in args if a]
675 675
676 if self.name is not None and self.name in self.pages_redirects: 676 if self.name is not None and self.name in self.pages_redirects:
677 #  we check for redirection 677 #  we check for redirection
683 url_base = redirect_data[current_hash] 683 url_base = redirect_data[current_hash]
684 remaining = args[limit:] 684 remaining = args[limit:]
685 remaining_url = "/".join(remaining) 685 remaining_url = "/".join(remaining)
686 return os.path.join("/", url_base, remaining_url) 686 return os.path.join("/", url_base, remaining_url)
687 687
688 return os.path.join(self.url, *url_args) 688 return self.host.checkRedirection(
689 self.vhost_root,
690 os.path.join(self.url, *url_args)
691 )
689 692
690 def getCurrentURL(self, request): 693 def getCurrentURL(self, request):
691 """retrieve URL used to access this page 694 """retrieve URL used to access this page
692 695
693 @return(unicode): current URL 696 @return(unicode): current URL