From 1ffcee8ea412ff9891a27aff552b215625c68186 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Thu, 9 Jan 2020 09:36:39 +0800 Subject: [PATCH] - Fix: Treat UNLICENSED as special case for comparisons (so it is not confused with "Unlicense") --- lib/satisfies.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/satisfies.js b/lib/satisfies.js index 2ca81ed..c4ec099 100644 --- a/lib/satisfies.js +++ b/lib/satisfies.js @@ -4,6 +4,13 @@ const spdxSatisfies = require('spdx-satisfies'); const correct = require('spdx-correct'); +function correcting(spdx) { + if (spdx === 'UNLICENSED') { // See https://github.com/jslicense/spdx-correct.js/issues/3#issuecomment-279799556 + return spdx; + } + return correct(spdx); +} + /** * @param {string} a spdx * @param {string} b spdx @@ -13,8 +20,8 @@ module.exports = function satisfies(a, b) { if (a === b) { return true; } - const ac = correct(a); - const bc = correct(b); + const ac = correcting(a); + const bc = correcting(b); if (!ac || !bc) { return false; }