Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export const whenChecker = (whenValue: string | undefined): boolean => {
return true;
}
// 先把变量解析出来
const valExpArr = whenValue.split(/([+\-*\/()><!]|>=|<=|==|&&|\|\||!=)/g);
// 多字符运算符必须排在单字符之前,否则 >= 会被拆成 > 和 =xxx,导致右侧变量无法被识别
const valExpArr = whenValue.split(/(>=|<=|==|!=|&&|\|\||[+\-*\/()><!])/g);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve strict inequality tokenization

When a condition uses the valid !== operator with a bare variable on the right, this ordering now splits left!==right into left, !=, and =right. The lookup therefore targets the nonexistent key =right, and the reconstructed expression compares against an unresolved right identifier rather than its stored value; for example, two equal variables can incorrectly make left!==right true. Previously ! followed by == preserved this expression, so !== should be recognized before !=.

Useful? React with 👍 / 👎.

const valExp = valExpArr
.map((_e) => {
const e = _e.trim();
Expand Down
Loading