diff --git a/index.js b/index.js index ce02993..ef804ec 100644 --- a/index.js +++ b/index.js @@ -5,10 +5,10 @@ const Transform = require('stream').Transform const SPEC_ALGORITHMS = ['sha256', 'sha384', 'sha512'] -const BASE64_REGEX = /[a-z0-9+/]+(?:=?=?)/i +const BASE64_REGEX = /^[a-z0-9+/]+(?:=?=?)$/i const SRI_REGEX = /^([^-]+)-([^?]+)([?\S*]*)$/ const STRICT_SRI_REGEX = /^([^-]+)-([A-Za-z0-9+/]+(?:=?=?))([?\x21-\x7E]*)$/ -const VCHAR_REGEX = /[\x21-\x7E]+/ +const VCHAR_REGEX = /^[\x21-\x7E]+$/ class IntegrityMetadata { constructor (metadata, opts) { @@ -75,7 +75,7 @@ class Integrity { const other = typeof integrity === 'string' ? integrity : stringify(integrity, opts) - return parse(`${this.toString()} ${other}`, opts) + return parse(`${this.toString(opts)} ${other}`, opts) } }