From: alexlamsl Date: Fri, 16 Sep 2016 06:14:42 +0000 (+0800) Subject: fix erroneous trailing whitespace detection X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=85b34b4366fa2dae6bb974c1c1d27c8f484b5542;p=html-minifier.git fix erroneous trailing whitespace detection fixes #713 --- diff --git a/src/htmlminifier.js b/src/htmlminifier.js index 2a6f3f7..a4b5442 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -1138,7 +1138,11 @@ function minify(value, options, partialMarkup) { if (prevTag) { if (prevTag === '/nobr' || prevTag === 'wbr') { if (/^\s/.test(text)) { - trimTrailingWhitespace(buffer.length - 2, 'br'); + var tagIndex = buffer.length - 1; + while (tagIndex > 0 && buffer[tagIndex].lastIndexOf('<' + prevTag) !== 0) { + tagIndex--; + } + trimTrailingWhitespace(tagIndex - 1, 'br'); } } else if (inlineTextTags(prevTag.charAt(0) === '/' ? prevTag.slice(1) : prevTag)) {