redirector: handle case where thread id can have an .html extension, because of course it can...
This commit is contained in:
parent
5859ee0408
commit
7157757d43
@ -42,6 +42,8 @@ def make_forum_url (request):
|
|||||||
post_id = None
|
post_id = None
|
||||||
|
|
||||||
if thread_id:
|
if thread_id:
|
||||||
|
thread_id = strip_extension(thread_id)
|
||||||
|
|
||||||
if "." in thread_id:
|
if "." in thread_id:
|
||||||
(thread_id, post_id) = thread_id.split(".")
|
(thread_id, post_id) = thread_id.split(".")
|
||||||
post_id = post_id[len("msg"):]
|
post_id = post_id[len("msg"):]
|
||||||
@ -67,6 +69,12 @@ def make_forum_url (request):
|
|||||||
|
|
||||||
return url
|
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):
|
def read_thread_index (forums_archive):
|
||||||
with urllib.request.urlopen("{}{}".format(forums_archive, FORUM_THREAD_INDEX)) as gzipped_in:
|
with urllib.request.urlopen("{}{}".format(forums_archive, FORUM_THREAD_INDEX)) as gzipped_in:
|
||||||
data = gzipped_in.read()
|
data = gzipped_in.read()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user