Add absolutize_link util

main
Tristan Daniël Maat 2022-04-09 23:06:16 +01:00
parent 8820ce1b95
commit ff7b03bc2b
Signed by: tlater
GPG Key ID: 49670FD774E43268
1 changed files with 7 additions and 0 deletions

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