From 1ab1efafa3b986c769f9b25aec05f4816cc53c5b Mon Sep 17 00:00:00 2001 From: Salvatore Mesoraca Date: Fri, 13 Dec 2024 17:02:49 +0100 Subject: [PATCH] Allow relative path in unix socket URLs Close #123 Signed-off-by: Salvatore Mesoraca --- valkey/_parsers/url_parser.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/valkey/_parsers/url_parser.py b/valkey/_parsers/url_parser.py index b85b18e6..5f26cdd0 100644 --- a/valkey/_parsers/url_parser.py +++ b/valkey/_parsers/url_parser.py @@ -40,10 +40,11 @@ def parse_url(url: str, async_connection: bool): supported_schemes = ["valkey", "valkeys", "redis", "rediss", "unix"] parsed: ParseResult = urlparse(url) kwargs: ConnectKwargs = {} + lower_url = url.lower() pattern = re.compile( - r"^(?:" + "|".join(map(re.escape, supported_schemes)) + r")://", re.IGNORECASE + r"^(?:" + "|".join(map(re.escape, supported_schemes)) + r")://" ) - if not pattern.match(url): + if not pattern.match(lower_url) and not lower_url.startswith("unix:"): raise ValueError( f"Valkey URL must specify one of the following schemes {supported_schemes}" )