mirror of
https://github.com/rails/execjs
synced 2023-03-27 23:21:20 -04:00
Fix sub \ escaping
This commit is contained in:
parent
998de3c0ff
commit
bd4c71c224
2 changed files with 5 additions and 1 deletions
|
@ -37,7 +37,9 @@ module ExecJS
|
||||||
|
|
||||||
def compile(source)
|
def compile(source)
|
||||||
@runtime.send(:runner_source).dup.tap do |output|
|
@runtime.send(:runner_source).dup.tap do |output|
|
||||||
output.sub!('#{source}', source)
|
output.sub!('#{source}') do
|
||||||
|
source
|
||||||
|
end
|
||||||
output.sub!('#{json2_source}') do
|
output.sub!('#{json2_source}') do
|
||||||
IO.read(ExecJS.root + "/support/json2.js")
|
IO.read(ExecJS.root + "/support/json2.js")
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,6 +14,7 @@ module TestRuntime
|
||||||
assert_equal "hello", @runtime.exec("return 'hello'")
|
assert_equal "hello", @runtime.exec("return 'hello'")
|
||||||
assert_equal({"a"=>1,"b"=>2}, @runtime.exec("return {a:1,b:2}"))
|
assert_equal({"a"=>1,"b"=>2}, @runtime.exec("return {a:1,b:2}"))
|
||||||
assert_equal "café", @runtime.exec("return 'café'")
|
assert_equal "café", @runtime.exec("return 'café'")
|
||||||
|
assert_equal "\\", @runtime.exec('return "\\\\"')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_eval
|
def test_eval
|
||||||
|
@ -27,6 +28,7 @@ module TestRuntime
|
||||||
assert_equal "hello", @runtime.eval("'hello'")
|
assert_equal "hello", @runtime.eval("'hello'")
|
||||||
assert_equal({"a"=>1,"b"=>2}, @runtime.eval("{a:1,b:2}"))
|
assert_equal({"a"=>1,"b"=>2}, @runtime.eval("{a:1,b:2}"))
|
||||||
assert_equal "café", @runtime.eval("'café'")
|
assert_equal "café", @runtime.eval("'café'")
|
||||||
|
assert_equal "\\", @runtime.eval('"\\\\"')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_compile
|
def test_compile
|
||||||
|
|
Loading…
Reference in a new issue