Skip to content

World's first open-source enterprise world model.

A rule's set values split on the comma a Chinese input method types (#1283)

Maya Kide6c75e5db5a3
diff --git a/web/src/pages/RulesPanel.tsx b/web/src/pages/RulesPanel.tsx
index f6e2e632..ff3077b9 100644
--- a/web/src/pages/RulesPanel.tsx
+++ b/web/src/pages/RulesPanel.tsx
@@ -100,8 +100,12 @@ export function parseOperand(op: string, text: string): unknown | undefined {
const t = text.trim();
if (!t) return undefined;
if (kind === "set") {
+ // **全角逗号也是分隔符**:中文输入法敲出来的逗号是「,」。从前只认半角,
+ // 「气测异常,气测异常后效」存成了一个成员——「属于」永不成立,
+ // 「不属于」对任何值都成立。metadataOnly 故意不锁含「,」的成员,好让
+ // 这样存下的旧规则打开再保存一次就修好;代价是经 API 写进的也会被拆开
const set = t
- .split(",")
+ .split(/[,,]/)
.map((s) => s.trim())
.filter(Boolean);
return set.length ? set : undefined;
diff --git a/web/src/pages/ruleSetOperands.test.ts b/web/src/pages/ruleSetOperands.test.ts
new file mode 100644
index 00000000..ac11e685
--- /dev/null
+++ b/web/src/pages/ruleSetOperands.test.ts
@@ -0,0 +1,9 @@
+import { describe, expect, it } from "vitest";
+import { parseOperand } from "./RulesPanel";
+
+describe("rule set operands", () => {
+ it.each(["in", "not_in"])("splits %s members on the comma a Chinese input method types", (op) => {
+ expect(parseOperand(op, "气测异常,气测异常后效")).toEqual(["气测异常", "气测异常后效"]);
+ expect(parseOperand(op, "气测异常,气测异常后效, 气层")).toEqual(["气测异常", "气测异常后效", "气层"]);
+ });
+});