Skip to content

Commit fa7a3b5

Browse files
authored
Merge pull request #293 from pre-commit/dont_match_whitespace_regex
Improve vcs regex (don't match whitespace)
2 parents bf8369c + c72ad40 commit fa7a3b5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pre_commit_hooks/check_vcs_permalinks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
GITHUB_NON_PERMALINK = re.compile(
11-
b'https://github.com/[^/]+/[^/]+/blob/master/[^# ]+#L\d+',
11+
b'https://github.com/[^/ ]+/[^/ ]+/blob/master/[^# ]+#L\d+',
1212
)
1313

1414

tests/check_vcs_permalinks_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ def test_passing(tmpdir):
1515
# permalinks are ok
1616
b'https://github.com/asottile/test/blob/649e6/foo%20bar#L1\n'
1717
# links to files but not line numbers are ok
18-
b'https://github.com/asottile/test/blob/master/foo%20bar\n',
18+
b'https://github.com/asottile/test/blob/master/foo%20bar\n'
19+
# regression test for overly-greedy regex
20+
b'https://github.com/ yes / no ? /blob/master/foo#L1\n',
1921
)
2022
assert not main((f.strpath,))
2123

0 commit comments

Comments
 (0)