From 3a7a5da59b6740227dc5da158662e31c9ddb50a9 Mon Sep 17 00:00:00 2001 From: Konstantin Alekseev Date: Mon, 25 Nov 2024 17:00:05 +0200 Subject: [PATCH] Fix db number parsing For cases like `redis:///tmp/devenv-277cd7a/redis.sock/0` the regex will match 277 as db number. --- django_cache_url/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_cache_url/__init__.py b/django_cache_url/__init__.py index 2511a66..e67dabe 100644 --- a/django_cache_url/__init__.py +++ b/django_cache_url/__init__.py @@ -93,7 +93,7 @@ def parse(url): config['LOCATION'] = 'unix://' + path elif url.scheme in ('redis', 'hiredis'): - match = re.match(r'.+?(?P\d+)', path) + match = re.match(r'.+?(?P\d+)$', path) if match: db = match.group('db') path = path[:path.rfind('/')]