aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Andi Qu <[email protected]>2021-01-24 19:59:49 +0200
committerGravatar GitHub <[email protected]>2021-01-24 19:59:49 +0200
commitae5e1c64983431e1bcac1fc9a50255fdc32777ee (patch)
treede033f6ef0a45144bcce2b30c2178c941f2ce183
parentDon't match dashes in GitHub gist revisions (diff)
Add matching for query params to all the regexes
-rw-r--r--bot/exts/info/code_snippets.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/bot/exts/info/code_snippets.py b/bot/exts/info/code_snippets.py
index 44f11cdbd..3f943aea8 100644
--- a/bot/exts/info/code_snippets.py
+++ b/bot/exts/info/code_snippets.py
@@ -14,12 +14,12 @@ 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>[^#>]+/{0,1})(\?[^#>]+)?(#L(?P<start_line>\d+)([-~:]L(?P<end_line>\d+))?)'
)
GITHUB_GIST_RE = re.compile(
r'https://gist\.github\.com/([a-zA-Z0-9-]+)/(?P<gist_id>[a-zA-Z0-9]+)/*'
- r'(?P<revision>[a-zA-Z0-9]*)/*#file-(?P<file_path>[^#>]+?)'
+ r'(?P<revision>[a-zA-Z0-9]*)/*#file-(?P<file_path>[^#>]+?)(\?[^#>]+)?'
r'(-L(?P<start_line>\d+)([-~:]L(?P<end_line>\d+))?)'
)
@@ -27,7 +27,7 @@ GITHUB_HEADERS = {'Accept': 'application/vnd.github.v3.raw'}
GITLAB_RE = re.compile(
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+))?)'
+ r'(\?[^#>]+)?(#L(?P<start_line>\d+)(-(?P<end_line>\d+))?)'
)
BITBUCKET_RE = re.compile(