(
base_url: Optional[str],
url_string: str,
match: Optional[URLMatch],
websocket_url: bool = None,
)
| 153 | |
| 154 | |
| 155 | def url_matches( |
| 156 | base_url: Optional[str], |
| 157 | url_string: str, |
| 158 | match: Optional[URLMatch], |
| 159 | websocket_url: bool = None, |
| 160 | ) -> bool: |
| 161 | if not match: |
| 162 | return True |
| 163 | if isinstance(match, str): |
| 164 | match = re.compile( |
| 165 | resolve_glob_to_regex_pattern(base_url, match, websocket_url) |
| 166 | ) |
| 167 | if isinstance(match, Pattern): |
| 168 | return bool(match.search(url_string)) |
| 169 | return match(url_string) |
| 170 | |
| 171 | |
| 172 | def resolve_glob_to_regex_pattern( |