Merge pull request #1760 from mtasaka/nil-nil-comparison-fix

change: make nil_safe_casecmp judge compatible for nil-nil comparison
This commit is contained in:
Ian Ker-Seymer
2024-03-21 15:38:13 -04:00
committed by GitHub
2 changed files with 3 additions and 1 deletions
+2
View File
@@ -944,6 +944,8 @@ module Liquid
def nil_safe_casecmp(a, b)
if !a.nil? && !b.nil?
a.to_s.casecmp(b.to_s)
elsif a.nil? && b.nil?
0
else
a.nil? ? 1 : -1
end
+1 -1
View File
@@ -331,8 +331,8 @@ class StandardFiltersTest < Minitest::Test
{ "price" => "1", "handle" => "gamma" },
{ "price" => 2, "handle" => "epsilon" },
{ "price" => "4", "handle" => "alpha" },
{ "handle" => "delta" },
{ "handle" => "beta" },
{ "handle" => "delta" },
]
assert_equal(expectation, @filters.sort_natural(input, "price"))
end