comparison piecrust/serving/util.py @ 732:dfd9f5ee4622

serve: Fix some problems with trailing slashes.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 01 Jun 2016 22:11:29 -0700
parents 606f6d57b5df
children 673979a5d548
comparison
equal deleted inserted replaced
731:dafb7d76c2ba 732:dfd9f5ee4622
46 gen_res.append((route, metadata, is_sub_page)) 46 gen_res.append((route, metadata, is_sub_page))
47 return res + gen_res 47 return res + gen_res
48 48
49 49
50 def get_requested_page(app, req_path): 50 def get_requested_page(app, req_path):
51 # Remove the trailing slash to simplify how we parse URLs.
52 if req_path != '/':
53 req_path = req_path.rstrip('/')
54
51 # Try to find what matches the requested URL. 55 # Try to find what matches the requested URL.
52 routes = find_routes(app.routes, req_path) 56 routes = find_routes(app.routes, req_path)
53 57
54 # It could also be a sub-page (i.e. the URL ends with a page number), so 58 # It could also be a sub-page (i.e. the URL ends with a page number), so
55 # we try to also match the base URL (without the number). 59 # we try to also match the base URL (without the number).