aboutsummaryrefslogtreecommitdiffhomepage
path: root/publisher
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2020-04-21 12:57:45 +0200
committerBjørn Erik Pedersen <[email protected]>2020-04-21 21:00:52 +0200
commitf37e77f2d338cf876cfa637a662acd76f0f2009b (patch)
tree76e80b012377cb03e3e02ecf7c34760d0d337f52 /publisher
parent27af5a339a4d3c5712b5ed946a636a8c21916039 (diff)
downloadhugo-f37e77f2d338cf876cfa637a662acd76f0f2009b.tar.gz
hugo-f37e77f2d338cf876cfa637a662acd76f0f2009b.zip
Fix class collector when running with --minify
Also add a related stresstest. Fixes #7161
Diffstat (limited to 'publisher')
-rw-r--r--publisher/htmlElementsCollector.go5
-rw-r--r--publisher/htmlElementsCollector_test.go2
2 files changed, 2 insertions, 5 deletions
diff --git a/publisher/htmlElementsCollector.go b/publisher/htmlElementsCollector.go
index c6e0d3f0f..6166c49ad 100644
--- a/publisher/htmlElementsCollector.go
+++ b/publisher/htmlElementsCollector.go
@@ -87,11 +87,6 @@ func (w *cssClassCollectorWriter) Write(p []byte) (n int, err error) {
if w.isCollecting {
for ; i < len(p); i++ {
b := p[i]
- if !w.inQuote && b == '/' {
- // End element, we don't care about those.
- w.endCollecting(true)
- break
- }
w.toggleIfQuote(b)
if !w.inQuote && b == '>' {
w.endCollecting(false)
diff --git a/publisher/htmlElementsCollector_test.go b/publisher/htmlElementsCollector_test.go
index 3ef159d8b..fe3876ae6 100644
--- a/publisher/htmlElementsCollector_test.go
+++ b/publisher/htmlElementsCollector_test.go
@@ -51,6 +51,8 @@ func TestClassCollector(t *testing.T) {
{"duplicates", `<div class="b a b"></div>`, f("div", "a b", "")},
{"single quote", `<body class='b a'></body>`, f("body", "a b", "")},
{"no quote", `<body class=b id=myelement></body>`, f("body", "b", "myelement")},
+ // https://github.com/gohugoio/hugo/issues/7161
+ {"minified a href", `<a class="b a" href=/></a>`, f("a", "a b", "")},
{"AlpineJS bind 1", `<body>
<div x-bind:class="{