Skip to content

Commit

Permalink
Fix some Rubocop errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
parkr committed Oct 17, 2017
1 parent 5c91a11 commit 6d20916
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 1 addition & 3 deletions lib/jekyll/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,7 @@ def configure_include_paths
def configure_file_read_opts
self.file_read_opts = {}
self.file_read_opts[:encoding] = config["encoding"] if config["encoding"]
if self.file_read_opts[:encoding] && !self.file_read_opts[:encoding].start_with?("bom|")
self.file_read_opts[:encoding] = "bom|#{self.file_read_opts[:encoding]}"
end
self.file_read_opts = Jekyll::Utils.merged_file_read_opts(self, {})
end

private
Expand Down
14 changes: 8 additions & 6 deletions test/test_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -390,15 +390,17 @@ class TestUtils < JekyllUnitTest
end

should "add bom to encoding" do
opts = Utils.merged_file_read_opts(nil, { "encoding" => "utf-8", encoding: "utf-8" })
assert_equal "bom|utf-8", opts["encoding"]
assert_equal "bom|utf-8", opts[:encoding]
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 "preserve bom in encoding" do
opts = Utils.merged_file_read_opts(nil, { "encoding" => "bom|another", encoding: "bom|another" })
assert_equal "bom|another", opts["encoding"]
assert_equal "bom|another", opts[:encoding]
opts = { "encoding" => "bom|another", :encoding => "bom|another" }
merged = Utils.merged_file_read_opts(nil, opts)
assert_equal "bom|another", merged["encoding"]
assert_equal "bom|another", merged[:encoding]
end
end
end

0 comments on commit 6d20916

Please sign in to comment.