diff options
| author | 2021-01-19 21:14:19 +0200 | |
|---|---|---|
| committer | 2021-01-19 21:14:19 +0200 | |
| commit | e9f48d83d482502a846dd8d37cee6ab4c01fdf7e (patch) | |
| tree | 75c676092c805e5057c378681789d83605710e4c | |
| parent | Better GitHub regex (diff) | |
Account for query params in bitbucket
| -rw-r--r-- | bot/exts/info/code_snippets.py | 13 | 
1 files changed, 6 insertions, 7 deletions
| diff --git a/bot/exts/info/code_snippets.py b/bot/exts/info/code_snippets.py index 84f606036..75d8ac290 100644 --- a/bot/exts/info/code_snippets.py +++ b/bot/exts/info/code_snippets.py @@ -18,22 +18,21 @@ GITHUB_RE = re.compile(  )  GITHUB_GIST_RE = re.compile( -    r'https://gist\.github\.com/([^/]+)/(?P<gist_id>[^\W_]+)/*' -    r'(?P<revision>[^\W_]*)/*#file-(?P<file_path>\S+?)' +    r'https://gist\.github\.com/([^/]+)/(?P<gist_id>[a-zA-Z0-9]+)/*' +    r'(?P<revision>[a-zA-Z0-9-]*)/*#file-(?P<file_path>[^#>]+?)'      r'(-L(?P<start_line>\d+)([-~:]L(?P<end_line>\d+))?)'  )  GITHUB_HEADERS = {'Accept': 'application/vnd.github.v3.raw'}  GITLAB_RE = re.compile( -    r'https://gitlab\.com/(?P<repo>\S+?)/\-/blob/(?P<path>\S+/[^\s#,>]+)' -    r'(#L(?P<start_line>\d+)([-](?P<end_line>\d+))?)' +    r'https://gitlab\.com/(?P<repo>[a-zA-Z0-9-]+?)/\-/blob/(?P<path>[^#>]+/{0,1})' +    r'(#L(?P<start_line>\d+)(-(?P<end_line>\d+))?)'  )  BITBUCKET_RE = re.compile( -    r'https://bitbucket\.org/(?P<repo>\S+?)/src/' -    r'(?P<ref>\S+?)/(?P<file_path>[^\s#,>]+)' -    r'(#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+))?)'  ) | 
