Edgewall Software

Ticket #2553: base_url.patch

File base_url.patch, 0.6 KB (added by cmlenz, 3 years ago)

Use base_url when computing absolute URL of redirection

  • trac/web/api.py

     
    254254    If the `path` parameter is specified, the path is appended to the URL. 
    255255    Otherwise, only a URL with the components scheme, host and port is returned. 
    256256    """ 
     257    if hasattr(req, 'base_url'): 
     258        scheme, host, _, _, _, _ = urlparse.urlparse(req.base_url) 
     259        return urlparse.urlunparse((scheme, host, path, None, None, None)) 
     260 
    257261    host = req.get_header('Host') 
    258262    if req.get_header('X-Forwarded-Host'): 
    259263        host = req.get_header('X-Forwarded-Host')