We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f1731eb commit 3d927c1Copy full SHA for 3d927c1
fastapi_sio/utils.py
@@ -4,6 +4,14 @@
4
import re
5
6
7
+def match_origin(origin: str | None, pattern: str) -> bool:
8
+ """
9
+ Matches origin against a pattern.
10
11
+ return origin is not None and re.match(pattern, origin) is not None
12
+
13
14
15
def find_cors_configuration(app: FastAPI, default: Any) -> Any:
16
"""
17
Looks through FastAPI's middlewares to figure
@@ -23,6 +31,6 @@ def find_cors_configuration(app: FastAPI, default: Any) -> Any:
23
31
24
32
origins_regex = middleware.options.get("allow_origin_regex")
25
33
if origins_regex:
26
- return lambda value: re.match(origins_regex, value) is not None
34
+ return lambda origin: match_origin(origin, origins_regex)
27
35
28
36
return default
0 commit comments