Skip to content

Commit f7afc30

Browse files
author
DvirDukhan
committed
fixed double quate guard
1 parent 6c44609 commit f7afc30

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/graph.js

Lines changed: 2 additions & 2 deletions
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[paramValue.length - 1] != '"') || ((paramValue[paramValue.length - 1] == '"') && (paramValue[paramValue.length - 2] == '\\'))) strValue += '"';
7070
return strValue;
7171
}
7272
if (Array.isArray(paramValue)) {

test/redisGraphAPITest.js

Lines changed: 5 additions & 2 deletions
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)