From f6cbd2aeb19a79690f0c04411ce95fa87af383c8 Mon Sep 17 00:00:00 2001 From: boyska Date: Sat, 7 Dec 2024 19:46:28 +0100 Subject: [PATCH] shorten filenames --- caricari/private.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/caricari/private.py b/caricari/private.py index f8e1423..44fb8a7 100644 --- a/caricari/private.py +++ b/caricari/private.py @@ -58,11 +58,13 @@ def normalize_filename(filename: str): 'ciao' >>> normalize_filename("Hello, 42 worlds!") 'Hello42worlds' + >>> normalize_filename("Hey, do you want to hear my story?" * 10) + 'HeydoyouwanttohearmystoryHeydo' """ return "".join( c for c in filename if c.isalnum() or c in '-_' - ) + )[:40] @app.post("/upload") async def upload(