From 7157757d4377caa872b5e2d5e5d5646d70c12af1 Mon Sep 17 00:00:00 2001 From: Adrian Malacoda Date: Thu, 3 Sep 2020 04:12:54 -0500 Subject: [PATCH] redirector: handle case where thread id can have an .html extension, because of course it can... --- epilogue/redirector.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/epilogue/redirector.py b/epilogue/redirector.py index 108a808..ee6b708 100644 --- a/epilogue/redirector.py +++ b/epilogue/redirector.py @@ -42,6 +42,8 @@ def make_forum_url (request): post_id = None if thread_id: + thread_id = strip_extension(thread_id) + if "." in thread_id: (thread_id, post_id) = thread_id.split(".") post_id = post_id[len("msg"):] @@ -67,6 +69,12 @@ def make_forum_url (request): return url +def strip_extension (item): + for extension in [".html"]: + if item.endswith(extension): + item = item[:-len(extension)] + return item + def read_thread_index (forums_archive): with urllib.request.urlopen("{}{}".format(forums_archive, FORUM_THREAD_INDEX)) as gzipped_in: data = gzipped_in.read()