Add absolutize_link util

This commit is contained in:
Tristan Daniël Maat 2022-04-09 23:06:16 +01:00
parent 8820ce1b95
commit ff7b03bc2b
Signed by: tlater
GPG key ID: 49670FD774E43268

View file

@ -23,3 +23,10 @@ def read_links(f: TextIO) -> List[Link]:
reader = csv.reader(f)
next(reader) # Skip the header
return [Link(link[1], link[2]) for link in reader]
def absolutize_link(link: str, page_base: str) -> str:
"""Ensure we have an absolute url."""
if link.startswith("./"):
link = page_base + link[2:]
return link