Only enable BOM encoding option on UTF encodings (#8363)

Merge pull request 8363
This commit is contained in:
lm
2022-04-01 08:35:24 -05:00
committed by GitHub
parent 3c46d844cf
commit 2a0272cc38
2 changed files with 13 additions and 3 deletions

View File

@@ -408,13 +408,20 @@ class TestUtils < JekyllUnitTest
assert_nil opts[:encoding]
end
should "add bom to encoding" do
should "add bom to utf-encoding" do
opts = { "encoding" => "utf-8", :encoding => "utf-8" }
merged = Utils.merged_file_read_opts(nil, opts)
assert_equal "bom|utf-8", merged["encoding"]
assert_equal "bom|utf-8", merged[:encoding]
end
should "not add bom to non-utf encoding" do
opts = { "encoding" => "ISO-8859-1", :encoding => "ISO-8859-1" }
merged = Utils.merged_file_read_opts(nil, opts)
assert_equal "ISO-8859-1", merged["encoding"]
assert_equal "ISO-8859-1", merged[:encoding]
end
should "preserve bom in encoding" do
opts = { "encoding" => "bom|another", :encoding => "bom|another" }
merged = Utils.merged_file_read_opts(nil, opts)