From 0d75c1768732e641139b020cada1ce14678e77a5 Mon Sep 17 00:00:00 2001 From: "Kyle E. Mitchell" Date: Thu, 6 Jul 2023 15:38:29 -0700 Subject: [PATCH 1/3] Add GFDL range tests to README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) 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' From 4c14905255a1ad83698838bbeffa2440753de77f Mon Sep 17 00:00:00 2001 From: "Kyle E. Mitchell" Date: Thu, 6 Jul 2023 15:38:44 -0700 Subject: [PATCH 2/3] Don't normalize away range suffixes for GFDLs --- index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 0fd51df..3e97de8 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,14 @@ function normalizeGPLIdentifiers (argument) { return argument } +function startsWith (string, substring) { + return string.substring(0, substring.length) === substring +} + +if (!startsWith('applesauce', 'apple')) { + throw new Error('bad impl') +} + function endsWith (string, substring) { return string.indexOf(substring) === string.length - substring.length } From 2617c21bdbc22f47b50dc4a02ba6ec552b6130a0 Mon Sep 17 00:00:00 2001 From: "Kyle E. Mitchell" Date: Tue, 3 Oct 2023 11:06:36 -0700 Subject: [PATCH 3/3] Implement `startsWith` via `indexOf` --- index.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/index.js b/index.js index 3e97de8..d3023f4 100644 --- a/index.js +++ b/index.js @@ -77,11 +77,7 @@ function normalizeGPLIdentifiers (argument) { } function startsWith (string, substring) { - return string.substring(0, substring.length) === substring -} - -if (!startsWith('applesauce', 'apple')) { - throw new Error('bad impl') + return string.indexOf(substring) === 0 } function endsWith (string, substring) {