diff --git a/lib/filter.js b/lib/filter.js index 0973041..7cb9381 100644 --- a/lib/filter.js +++ b/lib/filter.js @@ -69,10 +69,14 @@ function minifyHtml (str, data) { // Return if a path matches exclusion pattern if (isMatch(path, exclude, globOptions)) return str - const result = Htmlminifier(str, options) - if (verbose) logFn.call(this, str, result, path, 'html') + try { + const result = Htmlminifier(str, options) + if (verbose) logFn.call(this, str, result, path, 'html') - return result + return result + } catch (err) { + throw new Error(err) + } } async function minifyCss (str, data) { diff --git a/test/html.test.js b/test/html.test.js index c7a0437..df444bf 100644 --- a/test/html.test.js +++ b/test/html.test.js @@ -103,4 +103,12 @@ describe('html', () => { expect(result).toBe(expected) }) + + test('invalid string', () => { + const invalid = '<>?:"{}|_+' + + expect(() => { + h(invalid, { path }) + }).toThrow('Parse Error') + }) })