diff --git a/html/html.go b/html/html.go index 8e84664c96..497a08dd0e 100644 --- a/html/html.go +++ b/html/html.go @@ -129,7 +129,7 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st var params map[string]string if rawTagHash == Iframe { mimetype = htmlMimeBytes - } else if len(rawTagMediatype) > 0 { + } else if 0 < len(rawTagMediatype) { mimetype, params = parse.Mediatype(rawTagMediatype) } else if rawTagHash == Script { mimetype = jsMimeBytes @@ -181,7 +181,7 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st if o.KeepWhitespace { break } - // remove when followed up by a block tag + // remove when followed by a block tag if next.Traits&blockTag != 0 { t.Data = t.Data[:len(t.Data)-1] omitSpace = false @@ -278,7 +278,7 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st omitSpace = true // omit spaces after block elements } - if len(t.Data) > 3+len(t.Text) { + if 3+len(t.Text) < len(t.Data) { t.Data[2+len(t.Text)] = '>' t.Data = t.Data[:3+len(t.Text)] } @@ -327,7 +327,7 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st for i := 0; i < len(content.AttrVal); i++ { if content.AttrVal[i] == '=' && i+2 < len(content.AttrVal) { i++ - if n := parse.Number(content.AttrVal[i:]); n > 0 { + if n := parse.Number(content.AttrVal[i:]); 0 < n { minNum := minify.Number(content.AttrVal[i:i+n], -1) if len(minNum) < n { copy(content.AttrVal[i:i+len(minNum)], minNum) @@ -434,10 +434,10 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st if len(val) == 0 { continue } - } else if len(attr.Text) > 2 && attr.Text[0] == 'o' && attr.Text[1] == 'n' { + } else if 2 < len(attr.Text) && attr.Text[0] == 'o' && attr.Text[1] == 'n' { // JS minifier for attribute inline code val = parse.TrimWhitespace(val) - if len(val) >= 11 && parse.EqualFold(val[:11], jsSchemeBytes) { + if 11 <= len(val) && parse.EqualFold(val[:11], jsSchemeBytes) { val = val[11:] } attrMinifyBuffer.Reset() @@ -475,7 +475,7 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st w.Write(spaceBytes) w.Write(attr.Text) - if len(val) > 0 && attr.Traits&booleanAttr == 0 { + if 0 < len(val) && attr.Traits&booleanAttr == 0 { w.Write(isBytes) // use double quotes for RDFa attributes