Skip to content

Commit

Permalink
merge: Parse 'hlink://' URIs as proper URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuestengecko committed Nov 8, 2024
2 parents f2d94ec + 4fb52d3 commit f68407e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions capellambse/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import sys
import time
import typing as t
import urllib.parse

import lxml.html
import markupsafe
Expand Down Expand Up @@ -546,16 +547,18 @@ def replace_hlinks(
"""

def cb(el: etree._Element) -> None:
if (
el.tag != "a"
or "href" not in el.attrib
or not el.attrib["href"].startswith("hlink://")
):
if el.tag != "a" or "href" not in el.attrib:
return
target = el.attrib["href"][8:]

try:
obj = model.by_uuid(target)
url = urllib.parse.urlparse(el.attrib["href"])
except ValueError:
return
if url.scheme != "hlink":
return

try:
obj = model.by_uuid(url.netloc)
except KeyError:
pass
else:
Expand Down

0 comments on commit f68407e

Please sign in to comment.