Skip to content

Commit

Permalink
Parse new full-post URL schema, close #2354
Browse files Browse the repository at this point in the history
  • Loading branch information
iBug committed Jul 30, 2018
1 parent 08a1373 commit 927ad75
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions parsing.py
Expand Up @@ -58,12 +58,12 @@ def fetch_post_id_and_site_from_url(url):
if url is None:
return None
trimmed_url = rebuild_str(url)
post_type_regex = r"\/\d+#\d+$"
post_type_regex = r"(?:\/\d+)?#\d+$"
post_type = ""
search_regex = ""
if regex.compile(post_type_regex).search(trimmed_url):
post_type = "answer"
search_regex = r"^(?:https?:)?\/\/([\w.]+)\/questions\/\d+\/.+\/(\d+)#\d+$"
search_regex = r"^(?:https?:)?\/\/([\w.]+)\/questions\/\d+\/.+[/#](\d+)(?:#\d+)?$"
else:
post_type = "question"
search_regex = r"^(?:https?:)?\/\/([\w.]+)/questions/(\d+)(?:/.*)?$"
Expand Down
1 change: 1 addition & 0 deletions test/test_parsing.py
Expand Up @@ -42,6 +42,7 @@
('http://stackexchange.com', to_protocol_relative, '//stackexchange.com'),
('https://stackexchange.com', to_protocol_relative, '//stackexchange.com'),
('//stackexchange.com', to_protocol_relative, '//stackexchange.com'),
('https://stackoverflow.com/questions/123456/hello-world#654321', fetch_post_id_and_site_from_url, ('654321', 'stackoverflow.com', 'answer')),
# ('sd 2tpu', preprocess_shortcut_command, 'sd tpu tpu'),
# ('sd - 3tpu fp', preprocess_shortcut_command, 'sd - tpu tpu tpu fp'),
# ('sd 3- 2fp', preprocess_shortcut_command, 'sd - - - fp fp'),
Expand Down

0 comments on commit 927ad75

Please sign in to comment.