From 3885557e7792d47c20a9fe4a3b6f34f832c11ea4 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 25 Oct 2024 02:00:15 -1000 Subject: [PATCH] adding / should only happen if netloc --- yarl/_path.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/yarl/_path.py b/yarl/_path.py index 2e024bc57..c805013c0 100644 --- a/yarl/_path.py +++ b/yarl/_path.py @@ -86,9 +86,7 @@ def calculate_relative_path(target: str, base: str) -> str: target_path_parts: Union[set[str], None] = None target_path_path = target_path.path - target_path_is_absolute = target[0] == "/" if target else True - base_path_is_absolute = base[0] == "/" if base else True - if target_path_is_absolute != base_path_is_absolute: + if (target and target[0] == "/") != (base and base[0] == "/"): raise ValueError( f"{target_path_path!r} and {base_path.path!r} have different anchors" )