Skip to content

Commit

Permalink
better pattern matching
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-genson committed Sep 14, 2024
1 parent 8eef143 commit 25e713c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mealie/repos/repository_cookbooks.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from collections.abc import Iterable

from fastapi import HTTPException, status
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 25e713c

Please sign in to comment.