summaryrefslogtreecommitdiff
path: root/pecan/core.py
diff options
context:
space:
mode:
Diffstat (limited to 'pecan/core.py')
-rw-r--r--pecan/core.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/pecan/core.py b/pecan/core.py
index 8155180..32185e5 100644
--- a/pecan/core.py
+++ b/pecan/core.py
@@ -368,13 +368,19 @@ class Pecan(object):
# lookup the controller, respecting content-type as requested
# by the file extension on the URI
path = request.pecan['routing_path']
+ request.pecan['extension'] = None
# attempt to guess the content type based on the file extension
if not request.pecan['content_type'] and '.' in path.split('/')[-1]:
- path, extension = splitext(path)
- request.pecan['extension'] = extension
+ new_path, extension = splitext(path)
+
# preface with a letter to ensure compat for 2.5
- request.pecan['content_type'] = guess_type('x' + extension)[0]
+ potential_type = guess_type('x' + extension)[0]
+
+ if potential_type is not None:
+ path = new_path
+ request.pecan['extension'] = extension
+ request.pecan['content_type'] = potential_type
controller, remainder = self.route(self.root, path)
cfg = _cfg(controller)