Skip to content

Commit

Permalink
fix: handle missing URL-scheme in og-tag
Browse files Browse the repository at this point in the history
  • Loading branch information
FAUSheppy committed Jul 22, 2024
1 parent d0b54d1 commit cce28e4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,11 @@ def cache_og_meta_icons(tiles):

try:

og_imge_href = og_image_tag.get("content")
urllib_image_request = urllib.request.Request(og_image_tag.get("content"))
og_image_href = og_image_tag.get("content")
if(not (og_image_href.startswith("https://")
or og_image_href.startswith.startswith("http://"))):
og_image_href = "https://{}".format(og_image_href)
urllib_image_request = urllib.request.Request(og_image_href)
urllib_image_request.add_header(USER_AGENT_HEADER, USER_AGENT_CONTENT)
image = urllib.request.urlopen(urllib_image_request).read()

Expand Down

0 comments on commit cce28e4

Please sign in to comment.