Skip to content

Commit 1d600cc

Browse files
committed
Roll back to \s in some cases where I don't have a test handy
1 parent 19c8e5d commit 1d600cc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

‎src/htmlminifier.js‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ function minify(value, options, partialMarkup) {
11201120
}
11211121
if (buffer.length > 1 && (!prevComment || !options.conservativeCollapse && / $/.test(currentChars))) {
11221122
var charsIndex = buffer.length - 2;
1123-
buffer[charsIndex] = buffer[charsIndex].replace(/[ \n\r\t\f]+$/, function(trailingSpaces) {
1123+
buffer[charsIndex] = buffer[charsIndex].replace(/\s+$/, function(trailingSpaces) {
11241124
text = trailingSpaces + text;
11251125
return '';
11261126
});
@@ -1138,7 +1138,7 @@ function minify(value, options, partialMarkup) {
11381138
}
11391139
}
11401140
else if (inlineTextTags(prevTag.charAt(0) === '/' ? prevTag.slice(1) : prevTag)) {
1141-
text = collapseWhitespace(text, options, /(?:^|[ \n\r\t\f])$/.test(currentChars));
1141+
text = collapseWhitespace(text, options, /(?:^|\s)$/.test(currentChars));
11421142
}
11431143
}
11441144
if (prevTag || nextTag) {
@@ -1147,7 +1147,7 @@ function minify(value, options, partialMarkup) {
11471147
else {
11481148
text = collapseWhitespace(text, options, true, true);
11491149
}
1150-
if (!text && /[ \n\r\t\f]$/.test(currentChars) && prevTag && prevTag.charAt(0) === '/') {
1150+
if (!text && /\s$/.test(currentChars) && prevTag && prevTag.charAt(0) === '/') {
11511151
trimTrailingWhitespace(buffer.length - 1, nextTag);
11521152
}
11531153
}
@@ -1167,18 +1167,18 @@ function minify(value, options, partialMarkup) {
11671167
if (options.removeOptionalTags && text) {
11681168
// <html> may be omitted if first thing inside is not comment
11691169
// <body> may be omitted if first thing inside is not space, comment, <meta>, <link>, <script>, <style> or <template>
1170-
if (optionalStartTag === 'html' || optionalStartTag === 'body' && !/^[ \n\r\t\f]/.test(text)) {
1170+
if (optionalStartTag === 'html' || optionalStartTag === 'body' && !/^\s/.test(text)) {
11711171
removeStartTag();
11721172
}
11731173
optionalStartTag = '';
11741174
// </html> or </body> may be omitted if not followed by comment
11751175
// </head>, </colgroup> or </caption> may be omitted if not followed by space or comment
1176-
if (compactTags(optionalEndTag) || looseTags(optionalEndTag) && !/^[ \n\r\t\f]/.test(text)) {
1176+
if (compactTags(optionalEndTag) || looseTags(optionalEndTag) && !/^\s/.test(text)) {
11771177
removeEndTag();
11781178
}
11791179
optionalEndTag = '';
11801180
}
1181-
charsPrevTag = /^[ \n\r\t\f]*$/.test(text) ? prevTag : 'comment';
1181+
charsPrevTag = /^\s*$/.test(text) ? prevTag : 'comment';
11821182
if (options.decodeEntities && text && !specialContentTags(currentTag)) {
11831183
// semi-colon can be omitted
11841184
// https://mathiasbynens.be/notes/ambiguous-ampersands

0 commit comments

Comments
 (0)