Commit 08908856 authored by Konrad Borowski's avatar Konrad Borowski

Avoid autolinking YouTrack issue numbers followed by letters

parent 9894f638
...@@ -6,9 +6,9 @@ class YoutrackService < IssueTrackerService ...@@ -6,9 +6,9 @@ class YoutrackService < IssueTrackerService
# {PROJECT-KEY}-{NUMBER} Examples: YT-1, PRJ-1, gl-030 # {PROJECT-KEY}-{NUMBER} Examples: YT-1, PRJ-1, gl-030
def self.reference_pattern(only_long: false) def self.reference_pattern(only_long: false)
if only_long if only_long
/(?<issue>\b[A-Za-z][A-Za-z0-9_]*-\d+)/ /(?<issue>\b[A-Za-z][A-Za-z0-9_]*-\d+\b)/
else else
/(?<issue>\b[A-Za-z][A-Za-z0-9_]*-\d+)|(#{Issue.reference_prefix}(?<issue>\d+))/ /(?<issue>\b[A-Za-z][A-Za-z0-9_]*-\d+\b)|(#{Issue.reference_prefix}(?<issue>\d+))/
end end
end end
......
...@@ -37,6 +37,10 @@ describe YoutrackService do ...@@ -37,6 +37,10 @@ describe YoutrackService do
it 'does allow project prefix on the reference' do it 'does allow project prefix on the reference' do
expect(described_class.reference_pattern.match('YT-123')[:issue]).to eq('YT-123') expect(described_class.reference_pattern.match('YT-123')[:issue]).to eq('YT-123')
end end
it 'does not allow issue number to be followed by a letter' do
expect(described_class.reference_pattern.match('YT-123A')).to eq(nil)
end
end end
context 'overriding properties' do context 'overriding properties' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment