From 6a6fd88ef5cc8183183dc500d2ca39615c0ea268 Mon Sep 17 00:00:00 2001 From: Jean byroot Boussier Date: Thu, 17 Feb 2022 15:20:41 +0100 Subject: [PATCH] Stop checking encoding names Comparing the names is much less efficient than comparing the instance directly. It may also change in the future: https://bugs.ruby-lang.org/issues/18576 --- lib/inky.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/inky.rb b/lib/inky.rb index 8c936f1..bcb042f 100644 --- a/lib/inky.rb +++ b/lib/inky.rb @@ -32,8 +32,8 @@ def initialize(options = {}) end def release_the_kraken(html_string) - if html_string.encoding.name == "ASCII-8BIT" - html_string.force_encoding('utf-8') # transform_doc barfs if encoding is ASCII-8bit + if html_string.encoding.name == Encoding::BINARY + html_string.force_encoding(Encoding::UTF_8) # transform_doc barfs if encoding is ASCII-8bit end html_string = html_string.gsub(/doctype/i, 'DOCTYPE') raws, str = Inky::Core.extract_raws(html_string)