diff --git a/pre_commit_hooks/check_vcs_permalinks.py b/pre_commit_hooks/check_vcs_permalinks.py index d67d5f5..139b41a 100644 --- a/pre_commit_hooks/check_vcs_permalinks.py +++ b/pre_commit_hooks/check_vcs_permalinks.py @@ -8,7 +8,7 @@ import sys GITHUB_NON_PERMALINK = re.compile( - b'https://github.com/[^/]+/[^/]+/blob/master/[^# ]+#L\d+', + b'https://github.com/[^/ ]+/[^/ ]+/blob/master/[^# ]+#L\d+', ) diff --git a/tests/check_vcs_permalinks_test.py b/tests/check_vcs_permalinks_test.py index 31fd608..00e5396 100644 --- a/tests/check_vcs_permalinks_test.py +++ b/tests/check_vcs_permalinks_test.py @@ -15,7 +15,9 @@ def test_passing(tmpdir): # permalinks are ok b'https://github.com/asottile/test/blob/649e6/foo%20bar#L1\n' # links to files but not line numbers are ok - b'https://github.com/asottile/test/blob/master/foo%20bar\n', + b'https://github.com/asottile/test/blob/master/foo%20bar\n' + # regression test for overly-greedy regex + b'https://github.com/ yes / no ? /blob/master/foo#L1\n', ) assert not main((f.strpath,))