diff --git a/lib/license_finder/license/definitions.rb b/lib/license_finder/license/definitions.rb index d9afbe18f..f1cc0f772 100644 --- a/lib/license_finder/license/definitions.rb +++ b/lib/license_finder/license/definitions.rb @@ -323,7 +323,7 @@ def mpl2 matcher = AnyMatcher.new( Matcher.from_template(Template.named('MPL2')), - HeaderMatcher.new(Matcher.from_regex(header_regexp)) + HeaderMatcher.new(Matcher.from_regex(header_regexp), 3) ) License.new( diff --git a/spec/lib/license_finder/license/definitions_spec.rb b/spec/lib/license_finder/license/definitions_spec.rb index 47ab0b788..75a041486 100644 --- a/spec/lib/license_finder/license/definitions_spec.rb +++ b/spec/lib/license_finder/license/definitions_spec.rb @@ -469,9 +469,21 @@ expect(subject).to be_matches_text 'Mozilla Public License, version 2.0' expect(subject).to be_matches_text 'Mozilla Public Licence version 2.0' - expect(subject).not_to be_matches_text "Something else\nMozilla Public License, version 2.0" expect(subject).not_to be_matches_text 'Mozilla Public License version 1.1' end + + it 'should return true if the text has a copyright header before the license' do + license_text_with_copyright = <<~TEXT + Copyright (c) 2026 My Company, Inc. + + Mozilla Public License, version 2.0 + TEXT + expect(subject).to be_matches_text license_text_with_copyright + end + + it 'should return true if the license text appears within the first few lines' do + expect(subject).to be_matches_text "Something else\nMozilla Public License, version 2.0" + end end end