diff --git a/package.json b/package.json index b84771ac41..e097b1a2f6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "redisgraph.js", - "version": "2.2.0", + "version": "2.2.1", "description": "Connect to RedisGraph 1.0.0 and up from JavaScript", "author": "RedisLabs", "license": "BSD 3", diff --git a/src/graph.js b/src/graph.js index 7d82838d4c..659f778cd5 100644 --- a/src/graph.js +++ b/src/graph.js @@ -63,10 +63,10 @@ class Graph { let paramType = typeof paramValue; if (paramType == "string") { let strValue = ""; - paramValue = paramValue.replace(/[\\"']/g, '\\$&'); + paramValue = paramValue.replace(/[\\"']/g, '\\$&'); if (paramValue[0] != '"') strValue += '"'; strValue += paramValue; - if (paramValue[paramValue.length - 1] != '"') strValue += '"'; + if (!paramValue.endsWith('"') || paramValue.endsWith("\\\"")) strValue += '"'; return strValue; } if (Array.isArray(paramValue)) { diff --git a/test/redisGraphAPITest.js b/test/redisGraphAPITest.js index ffcd892c3f..dbcb8299a5 100644 --- a/test/redisGraphAPITest.js +++ b/test/redisGraphAPITest.js @@ -412,11 +412,14 @@ describe("RedisGraphAPI Test", () => { [1, 2, 3], ["1", "2", "3"], null, - 'test"abc' + 'test"abc', + "test\"abc2", + "\"testabc3", + "testabc4\"" ]; let promises = []; for (var i = 0; i < params.length; i++) { - let param = { param: params[i] }; + let param = { param: params[i] }; promises.push(api.query("RETURN $param", param)); } let values = await Promise.all(promises);