diff --git a/src/lib.rs b/src/lib.rs index eda18f6..b58bf66 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,7 +38,9 @@ pub fn resolve_if(script: &str, data: &JsValue) -> Result { } } - let result = match engine.eval_expression_with_scope::(&mut scope, script) { + let altered = script.replace("'", "\""); + + let result = match engine.eval_expression_with_scope::(&mut scope, &altered) { Ok(res) => res, Err(e) => return Err(e.to_string()) }; diff --git a/test.js b/test.js index a68211b..6b7364b 100644 --- a/test.js +++ b/test.js @@ -54,6 +54,11 @@ var tests = { result: true, script: '["1", "2", "3"].contains(needle)', data: {'needle': '2'} + }, + 'test single quotes': { + result: true, + script: 'loader == \'vanilla\'', + data: {'loader': 'vanilla'} } }