Skip to content

Commit

Permalink
Remove outdated Encoding workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Mar 2, 2022
1 parent 610e88a commit d69363f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 38 deletions.
2 changes: 1 addition & 1 deletion lib/execjs/duktape_runtime.rb
Expand Up @@ -6,7 +6,7 @@ class DuktapeRuntime < Runtime
class Context < Runtime::Context
def initialize(runtime, source = "", options = {})
@ctx = Duktape::Context.new(complex_object: nil)
@ctx.exec_string(encode(source), '(execjs)')
@ctx.exec_string(source.encode(Encoding::UTF_8), '(execjs)')
rescue Exception => e
raise wrap_error(e)
end
Expand Down
26 changes: 0 additions & 26 deletions lib/execjs/encoding.rb

This file was deleted.

8 changes: 4 additions & 4 deletions lib/execjs/graaljs_runtime.rb
Expand Up @@ -8,7 +8,7 @@ def initialize(runtime, source = "", options = {})
@context.eval('js', 'delete this.console')
@js_object = @context.eval('js', 'Object')

source = encode(source)
source = source.encode(Encoding::UTF_8)
unless source.empty?
translate do
eval_in_context(source)
Expand All @@ -17,7 +17,7 @@ def initialize(runtime, source = "", options = {})
end

def exec(source, options = {})
source = encode(source)
source = source.encode(Encoding::UTF_8)
source = "(function(){#{source}})()" if /\S/.match?(source)

translate do
Expand All @@ -26,7 +26,7 @@ def exec(source, options = {})
end

def eval(source, options = {})
source = encode(source)
source = source.encode(Encoding::UTF_8)
source = "(#{source})" if /\S/.match?(source)

translate do
Expand All @@ -35,7 +35,7 @@ def eval(source, options = {})
end

def call(source, *args)
source = encode(source)
source = source.encode(Encoding::UTF_8)
source = "(#{source})" if /\S/.match?(source)

translate do
Expand Down
6 changes: 3 additions & 3 deletions lib/execjs/ruby_rhino_runtime.rb
Expand Up @@ -5,7 +5,7 @@ module ExecJS
class RubyRhinoRuntime < Runtime
class Context < Runtime::Context
def initialize(runtime, source = "", options = {})
source = encode(source)
source = source.encode(Encoding::UTF_8)

@rhino_context = ::Rhino::Context.new
fix_memory_limit! @rhino_context
Expand All @@ -15,15 +15,15 @@ def initialize(runtime, source = "", options = {})
end

def exec(source, options = {})
source = encode(source)
source = source.encode(Encoding::UTF_8)

if /\S/ =~ source
eval "(function(){#{source}})()", options
end
end

def eval(source, options = {})
source = encode(source)
source = source.encode(Encoding::UTF_8)

if /\S/ =~ source
unbox @rhino_context.eval("(#{source})")
Expand Down
4 changes: 0 additions & 4 deletions lib/execjs/runtime.rb
@@ -1,11 +1,7 @@
require "execjs/encoding"

module ExecJS
# Abstract base class for runtimes
class Runtime
class Context
include Encoding

def initialize(runtime, source = "", options = {})
end

Expand Down

0 comments on commit d69363f

Please sign in to comment.