File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 2
2
import re
3
3
from datetime import datetime , time
4
4
from pathlib import Path
5
+ from urllib .parse import urlparse
5
6
6
7
import yaml
7
8
from github import Auth , Github
45
46
re .DOTALL ,
46
47
)
47
48
49
+ # Set a default value of None for when the url field isn't as expected
50
+ valid_url = None
51
+
52
+ # Ensure the url field is not blank and the url matches the regex
53
+ if url_match is not None and url_match [1 ].strip () != "" :
54
+ # Parse the url and see if a scheme (`https`) is included in it
55
+ # If not, then prepend `https` to the url from the issue body
56
+ # This guards against the website thinking the passed in url is another page on https://blackpythondevs.com/
57
+ parsed_url = urlparse (url_match [1 ])
58
+ if "http" not in parsed_url .scheme .casefold ():
59
+ valid_url = f"https://{ url_match [1 ]} "
60
+
48
61
if dates_match :
49
62
conferenceDates = dates_match [1 ]
50
63
# Parse the end date of the conference
54
67
if endDate >= today :
55
68
conference = {
56
69
"name" : name_match [1 ],
57
- "url" : url_match [ 1 ] ,
70
+ "url" : valid_url ,
58
71
"dates" : dates_match [1 ],
59
72
"type" : type_match [1 ],
60
73
"location" : location_match [1 ],
You can’t perform that action at this time.
0 commit comments