Skip to content

Commit 46365d4

Browse files
committed
links: fix url joining
1 parent 0725d88 commit 46365d4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

library/utils/web.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,9 +639,11 @@ def construct_absolute_url(base_url, href):
639639
return href
640640

641641
if not up.netloc:
642-
if not base_url.endswith("/") and not href.startswith("/"):
643-
base_url += "/"
644-
642+
base_parsed = urlparse(base_url)
643+
path = base_parsed.path
644+
if not path.endswith("/") and path != "":
645+
path = path.rsplit("/", 1)[0] + "/"
646+
base_url = base_parsed._replace(path=path).geturl()
645647
href = urljoin(base_url, href)
646648

647649
if href.startswith("//"):

0 commit comments

Comments
 (0)