Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 1462

Show
Ignore:
Timestamp:
12/01/06 23:34:00
Author:
fumanchu
Message:

Clearer trailing-slash logic using endswith instead of slicing.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/__init__.py

    r1455 r1462  
    187187     
    188188    if request.app: 
    189         if path[:1] != "/"
     189        if not path.startswith("/")
    190190            # Append/remove trailing slash from path_info as needed 
    191191            # (this is to support mistyped URL's without redirecting; 
     
    193193            pi = request.path_info 
    194194            if request.is_index is True: 
    195                 if pi[-1:] != '/'
     195                if not pi.endswith('/')
    196196                    pi = pi + '/' 
    197197            elif request.is_index is False: 
    198                 if pi[-1:] == '/' and pi != '/': 
     198                if pi.endswith('/') and pi != '/': 
    199199                    pi = pi[:-1] 
    200200             
  • trunk/cherrypy/lib/cptools.py

    r1445 r1462  
    310310    if request.is_index is True: 
    311311        if missing: 
    312             if pi[-1:] != '/'
     312            if not pi.endswith('/')
    313313                new_url = cherrypy.url(pi + '/', request.query_string) 
    314314                raise cherrypy.HTTPRedirect(new_url) 
     
    316316        if extra: 
    317317            # If pi == '/', don't redirect to ''! 
    318             if pi[-1:] == '/' and pi != '/': 
     318            if pi.endswith('/') and pi != '/': 
    319319                new_url = cherrypy.url(pi[:-1], request.query_string) 
    320320                raise cherrypy.HTTPRedirect(new_url) 

Hosted by WebFaction

Log in as guest/cpguest to create tickets