diff --git a/lib/licensee/project_files/license_file.rb b/lib/licensee/project_files/license_file.rb index 05b258f..0039bdc 100644 --- a/lib/licensee/project_files/license_file.rb +++ b/lib/licensee/project_files/license_file.rb @@ -7,8 +7,8 @@ module Licensee PREFERRED_EXT = %w[md markdown txt].freeze PREFERRED_EXT_REGEX = /\.#{Regexp.union(PREFERRED_EXT)}\z/ - # Regex to match any extension except .spdx - NONSPDX_EXT_REGEX = %r{\.(?!spdx)[^./]+\z} + # Regex to match any extension except .spdx or .header + OTHER_EXT_REGEX = %r{\.(?!spdx|header)[^./]+\z}i # Regex to match, LICENSE, LICENCE, unlicense, etc. LICENSE_REGEX = /(un)?licen[sc]e/i @@ -28,17 +28,17 @@ module Licensee /\A#{LICENSE_REGEX}#{PREFERRED_EXT_REGEX}\z/ => 0.95, # LICENSE.md /\A#{COPYING_REGEX}\z/ => 0.90, # COPYING /\A#{COPYING_REGEX}#{PREFERRED_EXT_REGEX}\z/ => 0.85, # COPYING.md - /\A#{LICENSE_REGEX}#{NONSPDX_EXT_REGEX}\z/ => 0.80, # LICENSE.textile - /\A#{COPYING_REGEX}#{NONSPDX_EXT_REGEX}\z/ => 0.75, # COPYING.textile + /\A#{LICENSE_REGEX}#{OTHER_EXT_REGEX}\z/ => 0.80, # LICENSE.textile + /\A#{COPYING_REGEX}#{OTHER_EXT_REGEX}\z/ => 0.75, # COPYING.textile /\A#{LICENSE_REGEX}[-_]/ => 0.70, # LICENSE-MIT /\A#{COPYING_REGEX}[-_]/ => 0.65, # COPYING-MIT /[-_]#{LICENSE_REGEX}/ => 0.60, # MIT-LICENSE-MIT /[-_]#{COPYING_REGEX}/ => 0.55, # MIT-COPYING /\A#{OFL_REGEX}#{PREFERRED_EXT_REGEX}/ => 0.50, # OFL.md - /\A#{OFL_REGEX}#{NONSPDX_EXT_REGEX}/ => 0.45, # OFL.textile + /\A#{OFL_REGEX}#{OTHER_EXT_REGEX}/ => 0.45, # OFL.textile /\A#{OFL_REGEX}\z/ => 0.40, # OFL /\A#{PATENTS_REGEX}\z/ => 0.35, # PATENTS - /\A#{PATENTS_REGEX}#{NONSPDX_EXT_REGEX}\z/ => 0.30, # PATENTS.txt + /\A#{PATENTS_REGEX}#{OTHER_EXT_REGEX}\z/ => 0.30, # PATENTS.txt // => 0.00 # Catch all }.freeze diff --git a/lib/licensee/project_files/project_file.rb b/lib/licensee/project_files/project_file.rb index 0a1e315..e1c8908 100644 --- a/lib/licensee/project_files/project_file.rb +++ b/lib/licensee/project_files/project_file.rb @@ -66,7 +66,7 @@ module Licensee def copyright? return false unless is_a?(LicenseFile) return false unless matcher.is_a?(Matchers::Copyright) - filename =~ /\Acopyright(?:#{LicenseFile::NONSPDX_EXT_REGEX})?\z/i + filename =~ /\Acopyright(?:#{LicenseFile::OTHER_EXT_REGEX})?\z/i end end end diff --git a/spec/licensee/project_files/license_file_spec.rb b/spec/licensee/project_files/license_file_spec.rb index 808a0f7..1c7239d 100644 --- a/spec/licensee/project_files/license_file_spec.rb +++ b/spec/licensee/project_files/license_file_spec.rb @@ -109,11 +109,11 @@ RSpec.describe Licensee::ProjectFiles::LicenseFile do context 'any extension regex' do it 'matches .foo' do - expect(described_class::NONSPDX_EXT_REGEX).to match('.foo') + expect(described_class::OTHER_EXT_REGEX).to match('.foo') end it 'does not match .md/foo' do - expect(described_class::NONSPDX_EXT_REGEX).to_not match('.md/foo') + expect(described_class::OTHER_EXT_REGEX).to_not match('.md/foo') end end