Prevent crash while setting Strict-Transport-Security security header

This commit is contained in:
Diwakar 2024-10-26 13:45:28 +07:00 committed by GitHub
parent d905bda000
commit 0a7bc50279
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -60,7 +60,7 @@ def set_hsts(value: str):
pattern = r"^max-age=(\d+)(;includeSubDomains)?(;preload)?$"
match = re.match(pattern, value, re.IGNORECASE)
if not match:
return "max-age=31536000;includeSubDomains"
value = "max-age=31536000;includeSubDomains"
return {"Strict-Transport-Security": value}