aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Andi Qu <[email protected]>2021-01-13 19:10:03 +0200
committerGravatar Andi Qu <[email protected]>2021-01-13 19:10:03 +0200
commit1856ed852515c17c2095c10b93d4d418787ec178 (patch)
tree043e22eade57a838995202964625bdb212efeb5c
parentBetter regex, moved pattern handlers to __init__, and constant header (diff)
Better regex now works for <link>
-rw-r--r--bot/exts/info/code_snippets.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/bot/exts/info/code_snippets.py b/bot/exts/info/code_snippets.py
index 1899b139b..1d1bc2850 100644
--- a/bot/exts/info/code_snippets.py
+++ b/bot/exts/info/code_snippets.py
@@ -12,27 +12,27 @@ from bot.utils.messages import wait_for_deletion
log = logging.getLogger(__name__)
GITHUB_RE = re.compile(
- r'https://github\.com/(?P<repo>\S+?)/blob/(?P<path>\S+/[^\s#]+)'
- r'(#L(?P<start_line>\d+)([-~:]L(?P<end_line>\d+))?)?($|\s)'
+ r'https://github\.com/(?P<repo>\S+?)/blob/(?P<path>\S+/[^\s#,>]+)'
+ r'(#L(?P<start_line>\d+)([-~:]L(?P<end_line>\d+))?)?($|\s|,|>)'
)
GITHUB_GIST_RE = re.compile(
r'https://gist\.github\.com/([^/]+)/(?P<gist_id>[^\W_]+)/*'
r'(?P<revision>[^\W_]*)/*#file-(?P<file_path>\S+?)'
- r'(-L(?P<start_line>\d+)([-~:]L(?P<end_line>\d+))?)?($|\s)'
+ r'(-L(?P<start_line>\d+)([-~:]L(?P<end_line>\d+))?)?($|\s|,|>)'
)
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+))?)?($|\s)'
+ r'https://gitlab\.com/(?P<repo>\S+?)/\-/blob/(?P<path>\S+/[^\s#,>]+)'
+ r'(#L(?P<start_line>\d+)([-](?P<end_line>\d+))?)?($|\s|,|>)'
)
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+))?)?($|\s)'
+ r'(?P<ref>\S+?)/(?P<file_path>[^\s#,>]+)'
+ r'(#lines-(?P<start_line>\d+)(:(?P<end_line>\d+))?)?($|\s|,|>)'
)