diff --git a/lib/index.js b/lib/index.js index 1443137..222861a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -270,6 +270,9 @@ class Integrity { match (integrity, opts) { opts = ssriOpts(opts) const other = parse(integrity, opts) + if (!other) { + return false + } const algo = other.pickAlgorithm(opts) return ( this[algo] && diff --git a/test/integrity.js b/test/integrity.js index 1bc86c6..acd0a1e 100644 --- a/test/integrity.js +++ b/test/integrity.js @@ -108,6 +108,7 @@ test('match()', t => { }, 'returns the strongest match') t.notOk(sri.match('sha512-foo'), 'falsy when match fails') t.notOk(sri.match('sha384-foo'), 'falsy when match fails') + t.notOk(sri.match(null), 'falsy when integrity is null') t.end() })