spdx-correct
Advanced tools
Comparing version 3.0.2 to 3.1.0
21
index.js
/* | ||
Copyright 2015 Kyle E. Mitchell | ||
Copyright spdx-correct.js contributors | ||
@@ -280,3 +280,8 @@ Licensed under the Apache License, Version 2.0 (the "License"); | ||
module.exports = function (identifier) { | ||
module.exports = function (identifier, options) { | ||
options = options || {} | ||
var upgrade = options.upgrade === undefined ? true : !!options.upgrade | ||
function postprocess (value) { | ||
return upgrade ? upgradeGPLs(value) : value | ||
} | ||
var validArugment = ( | ||
@@ -291,11 +296,11 @@ typeof identifier === 'string' && | ||
if (valid(identifier)) { | ||
return upgradeGPLs(identifier) | ||
return postprocess(identifier) | ||
} | ||
var noPlus = identifier.replace(/\+$/, '').trim() | ||
if (valid(noPlus)) { | ||
return upgradeGPLs(noPlus) | ||
return postprocess(noPlus) | ||
} | ||
var transformed = validTransformation(identifier) | ||
if (transformed !== null) { | ||
return upgradeGPLs(transformed) | ||
return postprocess(transformed) | ||
} | ||
@@ -309,11 +314,11 @@ transformed = anyCorrection(identifier, function (argument) { | ||
if (transformed !== null) { | ||
return upgradeGPLs(transformed) | ||
return postprocess(transformed) | ||
} | ||
transformed = validLastResort(identifier) | ||
if (transformed !== null) { | ||
return upgradeGPLs(transformed) | ||
return postprocess(transformed) | ||
} | ||
transformed = anyCorrection(identifier, validLastResort) | ||
if (transformed !== null) { | ||
return upgradeGPLs(transformed) | ||
return postprocess(transformed) | ||
} | ||
@@ -320,0 +325,0 @@ return null |
{ | ||
"name": "spdx-correct", | ||
"description": "correct invalid SPDX expressions", | ||
"version": "3.0.2", | ||
"version": "3.1.0", | ||
"author": "Kyle E. Mitchell <kyle@kemitchell.com> (https://kemitchell.com)", | ||
@@ -9,3 +9,4 @@ "contributors": [ | ||
"Christian Zommerfelds <aero_super@yahoo.com>", | ||
"Tal Einat <taleinat@gmail.com>" | ||
"Tal Einat <taleinat@gmail.com>", | ||
"Dan Butvinik <butvinik@outlook.com>" | ||
], | ||
@@ -12,0 +13,0 @@ "dependencies": { |
@@ -10,2 +10,6 @@ ```javascript | ||
assert(correct('No idea what license') === null) | ||
// disable upgrade option | ||
assert(correct('GPL-3.0'), 'GPL-3.0-or-later') | ||
assert(correct('GPL-3.0', { upgrade: false }), 'GPL-3.0') | ||
``` |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
326
15
0
21616