Skip to content

Commit

Permalink
fix one more bug
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeGoodall committed Mar 6, 2024
1 parent b17f23f commit 9f91e00
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions application/routers/guidance_.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ def get_breadcrumbs(path):

def handleGuidanceRedirects(url_path, redirects):
for redirect in redirects:
if url_path[-1] == "/":
url_path = url_path[:-1]
if redirect["from"] == url_path:
url_path_copy = url_path
if url_path_copy[-1] == "/":
url_path_copy = url_path_copy[:-1]
if redirect["from"] == url_path_copy:
return RedirectResponse(url=redirect["to"], status_code=301)
return False

Expand All @@ -80,10 +81,6 @@ def handleGuidanceRedirects(url_path, redirects):
async def catch_all(request: Request, url_path: str):
index_file = "index"

# if URL path in this route is empty
if url_path == "":
url_path += index_file

# Some redirects from old guidance

# introduction
Expand All @@ -98,6 +95,13 @@ async def catch_all(request: Request, url_path: str):
if shouldRedirect:
return shouldRedirect

# if URL path in this route is empty
if url_path == "":
url_path += index_file
# if URL path in this route ends with /
elif url_path[-1] == "/":
url_path += index_file

# build string of the URL path and then the system path to the template file
root_url_path = "pages/guidance/"
url_path_to_file = root_url_path + url_path
Expand Down

0 comments on commit 9f91e00

Please sign in to comment.