Skip to content

Commit

Permalink
Drop base64 gem from dependency
Browse files Browse the repository at this point in the history
This following warning is shown in test.
```
/Users/ryunosuke.sato/src/github.com/lautis/uglifier/spec/spec_helper.rb:3: warning: base64 was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.4.0.
You can add base64 to your Gemfile or gemspec to silence this warning.
```

Instead of adding base64 to dependency, the usage of `Base64#strict_encode64` and `Base64#strict_decode64` have replaced with `Array#pack` and `String#unpack1`.
  • Loading branch information
tricknotes committed Sep 21, 2024
1 parent 0947f7c commit 89c6136
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/uglifier.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# encoding: UTF-8

require "json"
require "base64"
require "execjs"
require "uglifier/version"

Expand Down Expand Up @@ -160,7 +159,7 @@ def initialize(options = {})
def compile(source)
if @options[:source_map]
compiled, source_map = run_uglifyjs(source, true)
source_map_uri = Base64.strict_encode64(source_map)
source_map_uri = [source_map].pack('m0')
source_map_mime = "application/json;charset=utf-8;base64"
compiled + "\n//# sourceMappingURL=data:#{source_map_mime},#{source_map_uri}"
else
Expand Down Expand Up @@ -512,7 +511,7 @@ def input_source_map(source, generate_map)
source_map_options = @options[:source_map].is_a?(Hash) ? @options[:source_map] : {}
sanitize_map_root(source_map_options.fetch(:input_source_map) do
url = extract_source_mapping_url(source)
Base64.strict_decode64(url.split(",", 2)[-1]) if url && url.start_with?("data:")
url.split(",", 2)[-1].unpack1('m0') if url && url.start_with?("data:")
end)
rescue ArgumentError, JSON::ParserError
nil
Expand Down

0 comments on commit 89c6136

Please sign in to comment.