summaryrefslogtreecommitdiff
path: root/cherrypy/lib/cptools.py
diff options
context:
space:
mode:
authorRobert Brewer <fumanchu@aminus.org>2006-12-02 05:34:00 +0000
committerRobert Brewer <fumanchu@aminus.org>2006-12-02 05:34:00 +0000
commitde415757ec85d7a7f64add36c68f48e36d2fd7b4 (patch)
tree47ae191a21bf8bede2ce673a969c415093a6da9d /cherrypy/lib/cptools.py
parentb6d400dd88ad5925832ec9a743ea7230b1f09187 (diff)
downloadcherrypy-git-de415757ec85d7a7f64add36c68f48e36d2fd7b4.tar.gz
Clearer trailing-slash logic using endswith instead of slicing.
Diffstat (limited to 'cherrypy/lib/cptools.py')
-rw-r--r--cherrypy/lib/cptools.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/cherrypy/lib/cptools.py b/cherrypy/lib/cptools.py
index 8eff36ef..5b80a1c3 100644
--- a/cherrypy/lib/cptools.py
+++ b/cherrypy/lib/cptools.py
@@ -309,13 +309,13 @@ def trailing_slash(missing=True, extra=False):
if request.is_index is True:
if missing:
- if pi[-1:] != '/':
+ if not pi.endswith('/'):
new_url = cherrypy.url(pi + '/', request.query_string)
raise cherrypy.HTTPRedirect(new_url)
elif request.is_index is False:
if extra:
# If pi == '/', don't redirect to ''!
- if pi[-1:] == '/' and pi != '/':
+ if pi.endswith('/') and pi != '/':
new_url = cherrypy.url(pi[:-1], request.query_string)
raise cherrypy.HTTPRedirect(new_url)