From 25e713c064f73b7779f0c53381280ddc593a8e53 Mon Sep 17 00:00:00 2001 From: Michael Genson <71845777+michael-genson@users.noreply.github.com> Date: Sat, 14 Sep 2024 15:29:58 +0000 Subject: [PATCH] better pattern matching --- mealie/repos/repository_cookbooks.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mealie/repos/repository_cookbooks.py b/mealie/repos/repository_cookbooks.py index 5469c8de459..5d970c3249f 100644 --- a/mealie/repos/repository_cookbooks.py +++ b/mealie/repos/repository_cookbooks.py @@ -1,3 +1,4 @@ +import re from collections.abc import Iterable from fastapi import HTTPException, status @@ -35,8 +36,8 @@ def update(self, match_value: str | int | UUID4, data: SaveCookBook | dict) -> R data = SaveCookBook(**data) new_slug = slugify(data.name) - if not (data.slug and data.slug.startswith(new_slug)): - data.slug = slugify(data.name) + if not (data.slug and re.match(f"^({new_slug})(-\d+)?$", data.slug)): + data.slug = new_slug max_retries = 10 for i in range(max_retries):