Merge pull request #5000 from reitermarkus/7z

Don’t treat `.7z` as part of a version.
This commit is contained in:
Markus Reiter 2018-10-01 10:25:41 +02:00 committed by GitHub
commit bec5272c77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -200,7 +200,7 @@ class Pathname
return archive_ext if archive_ext
# Don't treat version numbers as extname.
return "" if basename.match?(/\b\d+\.\d+[^\.]*\Z/)
return "" if basename.match?(/\b\d+\.\d+[^\.]*\Z/) && !basename.end_with?(".7z")
File.extname(basename)
end

View File

@ -137,6 +137,11 @@ describe Pathname do
it "does not treat version numbers as extensions" do
expect(described_class.new("foo-0.1").extname).to eq("")
expect(described_class.new("foo-1.0-rc1").extname).to eq("")
expect(described_class.new("foo-1.2.3").extname).to eq ""
end
it "supports `.7z` with version numbers" do
expect(described_class.new("snap7-full-1.4.2.7z").extname).to eq ".7z"
end
end