correct-license-metadata
Advanced tools
Comparing version 1.0.1 to 1.1.0
31
index.js
@@ -11,7 +11,19 @@ var spdxExpressionValidate = require('spdx-expression-validate') | ||
var firstElement | ||
var unambiguous | ||
if (singular) { | ||
if (isValidExpression(singular)) return singular | ||
unambiguous = getUnambiguousCorrection(singular) | ||
if (unambiguous) return unambiguous | ||
if (isOneElementArray(singular)) { | ||
if (isValidExpression(singular[0])) return singular[0] | ||
} | ||
if (isOneElementArray(singular)) { | ||
firstElement = singular[0] | ||
if (isValidExpression(firstElement)) return firstElement | ||
if (typeof firstElement === 'object') { | ||
if (isValidExpression(firstElement.type)) return firstElement.type | ||
} | ||
} | ||
return false | ||
@@ -23,6 +35,6 @@ } | ||
if (isOneElementArray(plural)) { | ||
var first = plural[0] | ||
if (isValidExpression(first)) return first | ||
if (typeof first === 'object') { | ||
if (isValidExpression(first.type)) return first.type | ||
firstElement = plural[0] | ||
if (isValidExpression(firstElement)) return firstElement | ||
if (typeof firstElement === 'object') { | ||
if (isValidExpression(firstElement.type)) return firstElement.type | ||
} | ||
@@ -36,2 +48,13 @@ } | ||
function getUnambiguousCorrection (argument) { | ||
if (argument === 'Apache, Version 2.0') return 'Apache-2.0' | ||
if (argument === 'Apache License, Version 2.0') return 'Apache-2.0' | ||
if (argument === 'Apache 2.0') return 'Apache-2.0' | ||
if (argument === 'Apache 2') return 'Apache-2.0' | ||
if (argument === 'Apache v2') return 'Apache-2.0' | ||
if (argument === 'MIT/X11') return 'MIT' | ||
if (argument === 'LGPL 3') return 'LGPL-3.0' | ||
return false | ||
} | ||
function isValidExpression (argument) { | ||
@@ -38,0 +61,0 @@ return typeof argument === 'string' && spdxExpressionValidate(argument) |
{ | ||
"name": "correct-license-metadata", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "interpret old-style npm licenses arrays and other aberrations", | ||
@@ -5,0 +5,0 @@ "author": "Kyle E. Mitchell <kyle@kemitchell.com> (https://kemitchell.com/)", |
@@ -28,2 +28,21 @@ interpret old-style npm licenses arrays and other aberrations | ||
correct({ | ||
license: [ // old-style license array | ||
{ | ||
type: 'MIT', | ||
url: 'http://opensource.org/licenses/MIT' | ||
} | ||
] | ||
}), | ||
'MIT' | ||
) | ||
assert.strictEqual( | ||
correct({ | ||
license: "MIT/X11" | ||
}), | ||
'MIT' | ||
) | ||
assert.strictEqual( | ||
correct({ | ||
licenses: ['MIT'] // invalid | ||
@@ -30,0 +49,0 @@ }), |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4758
53
67