mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-24 21:56:05 +02:00
metrics: Fix divide by zero error
Under certain conditions, `howSimilarString` could reach a divide-by- zero situation which causes bogus values to print in the cache potential column of the template hints output. This situation essentially causes a `int(math.NaN())` value to be returned and hilarity ensues thereafter.
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
805b21555e
commit
6a5acd753a
@@ -43,6 +43,7 @@ func TestSimilarPercentage(t *testing.T) {
|
||||
c.Assert(howSimilar(template.HTML("Hugo Rules"), template.HTML("Hugo Rules")), qt.Equals, 100)
|
||||
c.Assert(howSimilar(map[string]any{"a": 32, "b": 33}, map[string]any{"a": 32, "b": 33}), qt.Equals, 100)
|
||||
c.Assert(howSimilar(map[string]any{"a": 32, "b": 33}, map[string]any{"a": 32, "b": 34}), qt.Equals, 0)
|
||||
c.Assert(howSimilar("\n", ""), qt.Equals, 100)
|
||||
}
|
||||
|
||||
type testStruct struct {
|
||||
|
Reference in New Issue
Block a user