Merge pull request #293 from pre-commit/dont_match_whitespace_regex

Improve vcs regex (don't match whitespace)
This commit is contained in:
Anthony Sottile 2018-06-04 10:58:13 -07:00 committed by GitHub
commit fa7a3b5466
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -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+',
)

View file

@ -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,))