diff --git a/README.md b/README.md index 2d175ea..2a28867 100644 --- a/README.md +++ b/README.md @@ -28,4 +28,9 @@ assert(satisfies( assert(satisfies('(MIT OR GPL-2.0)', '(ISC OR MIT)')) assert(satisfies('(MIT AND GPL-2.0)', '(MIT OR GPL-2.0)')) assert(!satisfies('(MIT AND GPL-2.0)', '(ISC OR GPL-2.0)')) + +// bring your own parser +satisfies('MIT', 'MIT', { + parse: function (expression) { return {license: 'MIT'} } +}) ``` diff --git a/index.js b/index.js index 2eb22a6..2f8f352 100644 --- a/index.js +++ b/index.js @@ -93,7 +93,7 @@ function normalizeGPLIdentifiers (argument) { argument.license = license.replace('-or-later', '') delete argument.plus } - } else { + } else if (argument.left && argument.right) { argument.left = normalizeGPLIdentifiers(argument.left) argument.right = normalizeGPLIdentifiers(argument.right) } @@ -104,7 +104,9 @@ function endsWith (string, substring) { return string.indexOf(substring) === string.length - 1 } -module.exports = function (first, second) { +module.exports = function (first, second, options) { + options = options || {} + parse = options.parse || parse return recurse( normalizeGPLIdentifiers(parse(first)), normalizeGPLIdentifiers(parse(second))