Don't allow duplicate URLs
All checks were successful
Build and Publish / build_and_publish (push) Successful in 31s
All checks were successful
Build and Publish / build_and_publish (push) Successful in 31s
This commit is contained in:
parent
fd00b98346
commit
24206d1e2f
1 changed files with 4 additions and 0 deletions
|
@ -106,6 +106,10 @@ async def create_redirect(
|
||||||
elif parsed.scheme not in ["http", "https"]:
|
elif parsed.scheme not in ["http", "https"]:
|
||||||
raise HTTPException(status_code=400, detail="Invalid URL - must be 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:
|
match slug_type:
|
||||||
case "urlsafe":
|
case "urlsafe":
|
||||||
slug = secrets.token_urlsafe(slug_length // 2)
|
slug = secrets.token_urlsafe(slug_length // 2)
|
||||||
|
|
Loading…
Reference in a new issue