main commit
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-10-16 16:30:25 +09:00
parent 91c7e04474
commit 537e7b363f
1146 changed files with 45926 additions and 77196 deletions

View File

@@ -1,6 +1,4 @@
from __future__ import annotations
from collections.abc import Sequence
import typing
from starlette.datastructures import URL, Headers
from starlette.responses import PlainTextResponse, RedirectResponse, Response
@@ -13,7 +11,7 @@ class TrustedHostMiddleware:
def __init__(
self,
app: ASGIApp,
allowed_hosts: Sequence[str] | None = None,
allowed_hosts: typing.Optional[typing.Sequence[str]] = None,
www_redirect: bool = True,
) -> None:
if allowed_hosts is None:
@@ -41,7 +39,9 @@ class TrustedHostMiddleware:
is_valid_host = False
found_www_redirect = False
for pattern in self.allowed_hosts:
if host == pattern or (pattern.startswith("*") and host.endswith(pattern[1:])):
if host == pattern or (
pattern.startswith("*") and host.endswith(pattern[1:])
):
is_valid_host = True
break
elif "www." + host == pattern: