mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-06 09:08:43 +08:00
fix: enhance isBalanced function to correctly count quote pairs (#40001)
- issue: #39999 Signed-off-by: SimFG <bang.fu@zilliz.com>
This commit is contained in:
parent
fd701eca71
commit
aba39ff98f
@ -281,8 +281,6 @@ Currently, the objects injected by expr include: <code>param</code>, <code>proxy
|
||||
function isBalanced(input) {
|
||||
const stack = [];
|
||||
const pairs = {
|
||||
"'": "'",
|
||||
'"': '"',
|
||||
'(': ')',
|
||||
'[': ']',
|
||||
'{': '}',
|
||||
@ -298,8 +296,18 @@ Currently, the objects injected by expr include: <code>param</code>, <code>proxy
|
||||
}
|
||||
}
|
||||
}
|
||||
let countDouble = 0;
|
||||
let countSingle = 0;
|
||||
|
||||
return stack.length === 0;
|
||||
for (let char of input) {
|
||||
if (char === '"') {
|
||||
countDouble += 1;
|
||||
} else if (char === "'") {
|
||||
countSingle += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return stack.length === 0 && countDouble % 2 === 0 && countSingle % 2 === 0;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user