From 0574263ab81c19f3349951d2b0c4cb3040980d2c Mon Sep 17 00:00:00 2001 From: Duncan Beevers Date: Wed, 20 Aug 2014 11:45:28 -0500 Subject: [PATCH] closing tag search is case-insensitive --- src/htmlparser.js | 7 ++++--- tests/minifier.js | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/htmlparser.js b/src/htmlparser.js index cf4dd23..a4447be 100644 --- a/src/htmlparser.js +++ b/src/htmlparser.js @@ -225,7 +225,6 @@ } else if ( html.indexOf('<') === 0 ) { match = html.match( startTag ); - if ( match ) { html = html.substring( match[0].length ); match[0].replace( startTag, parseStartTag ); @@ -376,9 +375,11 @@ if ( !tagName ) { pos = 0; } - else { // Find the closest opened tag of the same type + else { + // Find the closest opened tag of the same type + var needle = tagName.toLowerCase(); for ( pos = stack.length - 1; pos >= 0; pos-- ) { - if ( stack[ pos ].toLowerCase() === tagName ) { + if ( stack[ pos ].toLowerCase() === needle ) { break; } } diff --git a/tests/minifier.js b/tests/minifier.js index 7fba30c..72b35f5 100644 --- a/tests/minifier.js +++ b/tests/minifier.js @@ -56,6 +56,9 @@ equal(minify('ok'), 'ok'); equal(minify(''), ''); + + // https://github.com/kangax/html-minifier/issues/229 + equal(minify('
Hello :)
'), '
Hello :)
'); }); test('`minifiy` exists', function() { -- 2.34.1