From: Duncan Beevers Date: Wed, 20 Aug 2014 16:45:28 +0000 (-0500) Subject: closing tag search is case-insensitive X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=0574263ab81c19f3349951d2b0c4cb3040980d2c;p=html-minifier.git closing tag search is case-insensitive --- 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() {