diff --git a/src/main.py b/src/main.py index 42f74b1..d2bc978 100644 --- a/src/main.py +++ b/src/main.py @@ -106,6 +106,10 @@ async def create_redirect( elif parsed.scheme not in ["http", "https"]: raise HTTPException(status_code=400, detail="Invalid URL - must be HTTP/HTTPS") + existing = await db.Redirect.get_or_none(destination=destination) + if existing is not None: + return await db.RedirectPydantic.from_tortoise_orm(existing) + match slug_type: case "urlsafe": slug = secrets.token_urlsafe(slug_length // 2)