Skip to content

Commit c2b9d55

Browse files
authored
Merge pull request #56 from RedisGraph/fix_double_quate_guard
Fix double quote guard
2 parents 6c44609 + 09d5f3a commit c2b9d55

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "redisgraph.js",
3-
"version": "2.2.0",
3+
"version": "2.2.1",
44
"description": "Connect to RedisGraph 1.0.0 and up from JavaScript",
55
"author": "RedisLabs",
66
"license": "BSD 3",

Diff for: src/graph.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ class Graph {
6363
let paramType = typeof paramValue;
6464
if (paramType == "string") {
6565
let strValue = "";
66-
paramValue = paramValue.replace(/[\\"']/g, '\\$&');
66+
paramValue = paramValue.replace(/[\\"']/g, '\\$&');
6767
if (paramValue[0] != '"') strValue += '"';
6868
strValue += paramValue;
69-
if (paramValue[paramValue.length - 1] != '"') strValue += '"';
69+
if (!paramValue.endsWith('"') || paramValue.endsWith("\\\"")) strValue += '"';
7070
return strValue;
7171
}
7272
if (Array.isArray(paramValue)) {

Diff for: test/redisGraphAPITest.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -412,11 +412,14 @@ describe("RedisGraphAPI Test", () => {
412412
[1, 2, 3],
413413
["1", "2", "3"],
414414
null,
415-
'test"abc'
415+
'test"abc',
416+
"test\"abc2",
417+
"\"testabc3",
418+
"testabc4\""
416419
];
417420
let promises = [];
418421
for (var i = 0; i < params.length; i++) {
419-
let param = { param: params[i] };
422+
let param = { param: params[i] };
420423
promises.push(api.query("RETURN $param", param));
421424
}
422425
let values = await Promise.all(promises);

0 commit comments

Comments
 (0)