Skip to content

Ensure the conference URL always has a scheme #379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion _conferences/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import re
from datetime import datetime, time
from pathlib import Path
from urllib.parse import urlparse

import yaml
from github import Auth, Github
Expand Down Expand Up @@ -45,6 +46,18 @@
re.DOTALL,
)

# Set a default value of None for when the url field isn't as expected
valid_url = None

# Ensure the url field is not blank and the url matches the regex
if url_match is not None and url_match[1].strip() != "":
# Parse the url and see if a scheme (`https`) is included in it
# If not, then prepend `https` to the url from the issue body
# This guards against the website thinking the passed in url is another page on https://blackpythondevs.com/
parsed_url = urlparse(url_match[1])
if "http" not in parsed_url.scheme.casefold():
valid_url = f"https://{url_match[1]}"

if dates_match:
conferenceDates = dates_match[1]
# Parse the end date of the conference
Expand All @@ -54,7 +67,7 @@
if endDate >= today:
conference = {
"name": name_match[1],
"url": url_match[1],
"url": valid_url,
"dates": dates_match[1],
"type": type_match[1],
"location": location_match[1],
Expand Down
Loading