diff options
| author | 2021-01-30 11:43:14 +0200 | |
|---|---|---|
| committer | 2021-01-30 11:43:14 +0200 | |
| commit | 4dee6d3c4e18144b35011fc4441738a82fcb522b (patch) | |
| tree | aa7aaec915fbf6608db19ad895a641e4cac4e37b | |
| parent | Match both username *and* repo in the GitLab regex (diff) | |
Got rid of unnecessary regex matching things
Stuff like `/{0,1}` and `?` at the ends of groups
| -rw-r--r-- | bot/exts/info/code_snippets.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/bot/exts/info/code_snippets.py b/bot/exts/info/code_snippets.py index e825ec513..4c8de05fc 100644 --- a/bot/exts/info/code_snippets.py +++ b/bot/exts/info/code_snippets.py @@ -14,7 +14,7 @@ log = logging.getLogger(__name__) GITHUB_RE = re.compile( r'https://github\.com/(?P<repo>[a-zA-Z0-9-]+/[\w.-]+)/blob/' - r'(?P<path>[^#>]+/{0,1})(\?[^#>]+)?(#L(?P<start_line>\d+)([-~:]L(?P<end_line>\d+))?)' + r'(?P<path>[^#>]+)(\?[^#>]+)?(#L(?P<start_line>\d+)([-~:]L(?P<end_line>\d+))?)' ) GITHUB_GIST_RE = re.compile( @@ -26,13 +26,13 @@ GITHUB_GIST_RE = re.compile( GITHUB_HEADERS = {'Accept': 'application/vnd.github.v3.raw'} GITLAB_RE = re.compile( - r'https://gitlab\.com/(?P<repo>[\w.-]+/[\w.-]+)/\-/blob/(?P<path>[^#>]+/{0,1})' + r'https://gitlab\.com/(?P<repo>[\w.-]+/[\w.-]+)/\-/blob/(?P<path>[^#>]+)' r'(\?[^#>]+)?(#L(?P<start_line>\d+)(-(?P<end_line>\d+))?)' ) BITBUCKET_RE = re.compile( - r'https://bitbucket\.org/(?P<repo>[a-zA-Z0-9-]+/[\w.-]+?)/src/(?P<ref>[0-9a-zA-Z]+?)' - r'/(?P<file_path>[^#>]+?)(\?[^#>]+)?(#lines-(?P<start_line>\d+)(:(?P<end_line>\d+))?)' + r'https://bitbucket\.org/(?P<repo>[a-zA-Z0-9-]+/[\w.-]+)/src/(?P<ref>[0-9a-zA-Z]+)' + r'/(?P<file_path>[^#>]+)(\?[^#>]+)?(#lines-(?P<start_line>\d+)(:(?P<end_line>\d+))?)' ) |