Check whether the given origin matches the allowed origins.
(
origin: str,
allowed_literal_origins: list[str],
allowed_origin_regex: Optional[re.Pattern[str]],
)
| 125 | |
| 126 | |
| 127 | def _is_origin_allowed( |
| 128 | origin: str, |
| 129 | allowed_literal_origins: list[str], |
| 130 | allowed_origin_regex: Optional[re.Pattern[str]], |
| 131 | ) -> bool: |
| 132 | """Check whether the given origin matches the allowed origins.""" |
| 133 | if "*" in allowed_literal_origins: |
| 134 | return True |
| 135 | if origin in allowed_literal_origins: |
| 136 | return True |
| 137 | if allowed_origin_regex is not None: |
| 138 | return allowed_origin_regex.fullmatch(origin) is not None |
| 139 | return False |
| 140 | |
| 141 | |
| 142 | def _normalize_origin_scheme(scheme: str) -> str: |
no outgoing calls
no test coverage detected