Skip to content

Commit

Permalink
🐛 (notice): 修复招商银行信用卡预授权通知匹配问题 #439
Browse files Browse the repository at this point in the history
修复了招商银行信用卡预授权通知的正则表达式匹配问题,现在可以正确地解析预授权通知。

This commit fixes a regex issue in the matching of China Merchants Bank's credit card pre-authorization notification. Now the pre-authorization notifications can be parsed correctly.
  • Loading branch information
AnkioTomas committed Oct 18, 2024
1 parent daeaec0 commit 8abda31
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import { BillType, Currency, RuleObject, toFloat } from 'common/index.js';
export function get(data) {
let json = JSON.parse(data)
// 信用卡通知:您尾号1356的招行信用卡消费6225.34人民币。
let regex = /信用卡通知:您尾号(\d{4})的招行信用卡消费([\d,]+.\d{2})(.*?)。/
// 信用卡通知:您尾号1356的招行信用卡预授权1,362.41人民币。
let regex = /信用卡通知:您尾号(\d{4})的招行信用卡(消费|预授权)([\d,]+.\d{2})(.*?)。/
const match = json.text.match(regex);
if (!match) {
return null;
}
let [,number,money,currency] = match;
let [,number,,money,currency] = match;
let obj = new RuleObject();

obj.money = toFloat(money);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,16 @@ test('招商银行信用卡消费', () =>
"time": 1711393810000,
"channel": '招商银行[信用卡消费]',
},
{
"type": "Expend",
"money": 1362.41,
"fee": 0,
"shopName": '',
"shopItem": '',
"accountNameFrom": '招商银行信用卡(1356)',
"accountNameTo": '',
"currency": 'CNY',
"time": 1728923880764,
"channel": '招商银行[信用卡消费]',
},
]));
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"title": "招商银行",
"text": "信用卡通知:您尾号1356的招行信用卡预授权1,362.41人民币。",
"t": 1728923880764
}

0 comments on commit 8abda31

Please sign in to comment.