Skip to content

Commit

Permalink
Fixed an issue where the filename became to long
Browse files Browse the repository at this point in the history
  • Loading branch information
peterhpo committed Nov 5, 2024
1 parent 150d4ba commit 9f8e371
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions utleggs-og-kortskjema-automatisering/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import string

def sanitize_filename(filename):
def sanitize_filename(filename, max_length=100):
# Define valid characters, including æ, ø, å
valid_chars = f"-_.() {string.ascii_letters}{string.digits}æøåÆØÅ"
return ''.join(char if char in valid_chars else '_' for char in filename)
sanitized_filename = ''.join(char if char in valid_chars else '_' for char in filename)
return sanitized_filename[:max_length]

0 comments on commit 9f8e371

Please sign in to comment.