diff --git a/README.md b/README.md index 76c8b38..0cbc6f2 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,10 @@ assert(satisfies('GPL-2.0', 'GPL-2.0+')) assert(satisfies('GPL-2.0-only', 'GPL-2.0+')) assert(satisfies('GPL-2.0', 'GPL-2.0-or-later')) +assert(satisfies('GFDL-1.1-invariants-or-later', 'GFDL-1.2-invariants-only')) +assert(satisfies('GFDL-1.1-invariants-or-later', 'GFDL-1.2-invariants-or-later')) +assert(!satisfies('GFDL-1.1-invariants-only', 'GFDL-1.2-invariants-or-later')) + assert(!satisfies( 'GPL-2.0', 'GPL-2.0+ WITH Bison-exception-2.2' diff --git a/index.js b/index.js index 0fd51df..d3023f4 100644 --- a/index.js +++ b/index.js @@ -61,11 +61,12 @@ var licensesAreCompatible = function (first, second) { function normalizeGPLIdentifiers (argument) { var license = argument.license if (license) { + var isGFDL = startsWith(license, 'GFDL-') if (endsWith(license, '-or-later')) { - argument.license = license.replace('-or-later', '') + if (!isGFDL) argument.license = license.replace('-or-later', '') argument.plus = true } else if (endsWith(license, '-only')) { - argument.license = license.replace('-only', '') + if (!isGFDL) argument.license = license.replace('-only', '') delete argument.plus } } else if (argument.left && argument.right) { @@ -75,6 +76,10 @@ function normalizeGPLIdentifiers (argument) { return argument } +function startsWith (string, substring) { + return string.indexOf(substring) === 0 +} + function endsWith (string, substring) { return string.indexOf(substring) === string.length - substring.length }