Skip to content

Commit

Permalink
Remove iconv conditional require
Browse files Browse the repository at this point in the history
Drop legacy character encoding support for Ruby versions  prior to 1.9,
as string encoding is now natively supported in modern Ruby versions.
  • Loading branch information
tagliala committed Dec 12, 2024
1 parent 6f333cf commit b807af1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### Unreleased

* Remove `iconv` conditional require

### Version v1.19.1

* Fix error when parsing values consisting of `!important` only
Expand Down
1 change: 0 additions & 1 deletion lib/css_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
require 'digest/md5'
require 'zlib'
require 'stringio'
require 'iconv' unless String.method_defined?(:encode)

require 'css_parser/version'
require 'css_parser/rule_set'
Expand Down
7 changes: 1 addition & 6 deletions lib/css_parser/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -677,12 +677,7 @@ def read_remote_file(uri) # :nodoc:
end

if charset
if String.method_defined?(:encode)
src.encode!('UTF-8', charset)
else
ic = Iconv.new('UTF-8//IGNORE', charset)
src = ic.iconv(src)
end
src.encode!('UTF-8', charset)
end
rescue
@redirect_count = nil
Expand Down

0 comments on commit b807af1

Please sign in to comment.