mirror of https://github.com/licensee/licensee.git
license expression in package.json obtains other rather than nil
https://docs.npmjs.com/files/package.json#license can be a SPDX license expression rather than a SPDX license id. If expression found, makes sense to return other license rather than nil from package. So add space, plus, and parens to character class match as those can be part of a license expression.
This commit is contained in:
parent
00489bb3bf
commit
a6cfb6bd35
|
@ -4,7 +4,7 @@ module Licensee
|
|||
# While we could parse the package.json or bower.json file, prefer
|
||||
# a lenient regex for speed and security. Moar parsing moar problems.
|
||||
LICENSE_REGEX = /
|
||||
\s*[\"\']license[\"\']\s*\:\s*[\'\"]([a-z\-0-9\.]+)[\'\"],?\s*
|
||||
\s*[\"\']license[\"\']\s*\:\s*[\'\"]([a-z\-0-9\.+ ()]+)[\'\"],?\s*
|
||||
/ix
|
||||
|
||||
private
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "fake-package"
|
||||
"description": "Fake package available under various licenses",
|
||||
"license": "(MIT OR Apache-2.0 OR AGPL-3.0+)",
|
||||
"version": "0.1"
|
||||
}
|
|
@ -177,6 +177,15 @@ RSpec.describe 'integration test' do
|
|||
expect(subject.license).to eql(license)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with package.json license expression' do
|
||||
let(:fixture) { 'npm-license-expression' }
|
||||
let(:arguments) { { detect_packages: true } }
|
||||
|
||||
it 'matches other' do
|
||||
expect(subject.license).to eql(other_license)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with the license file stubbed' do
|
||||
|
|
Loading…
Reference in New Issue