Skip to content

Instantly share code, notes, and snippets.

@averykhoo
averykhoo / url_glob_pattern_matching.py
Created October 31, 2023 08:53
convert glob patterns to regex matchers, with support for globstar
import re
import warnings
from typing import Pattern
def translate_url_pattern(pattern: str, # noqa: max-complexity: 20
case_sensitive: bool = True,
) -> Pattern:
"""
translates a url pattern (like a glob pattern) to a regular expression