Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

correct-license-metadata

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

correct-license-metadata - npm Package Compare versions

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)

2

package.json
{
"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 @@ }),

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc