Skip to content

Commit

Permalink
🐛 (工商银行收支): 修复正则表达式以匹配无余额的交易通知
Browse files Browse the repository at this point in the history
修复了正则表达式无法匹配无余额的交易通知的问题,并添加了相应的测试用例。
  • Loading branch information
AnkioTomas committed Jan 23, 2025
1 parent 7ada7a0 commit 656a4b9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/rule/com.icbc/notice/工商银行收支/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ export function get (data) {
let json = JSON.parse(data);
// 尾号1054卡1月5日15:00收入(退款支付宝-支付宝-消费)3.70元,余额1,108.67元。
// 尾号1054卡1月12日15:56支出(消费支付宝-谢水生)4元,余额873.02元。
let regex = /(\d{4})(\d{1,2}\d{1,2}\d{1,2}:\d{1,2})(.*?)\(([^)]+)\)(.*?)/;
// 尾号9301卡1月18日16:00支出(缴费财付通-北京科技大学)5元。
let regex = /(\d{4})(\d{1,2}\d{1,2}\d{1,2}:\d{1,2})(.*?)\(([^)]+)\)(.*?)(?:)?/;
const match = json.text.match(regex);
if (!match) {
return null;
Expand Down
14 changes: 14 additions & 0 deletions src/rule/com.icbc/notice/工商银行收支/main.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

const { get } = require('./main');
const { testAnkio, testAnkioInit } = require('../../../../tests/TestUtils');
const { formatDate } = require('common/Time.js');
Expand Down Expand Up @@ -32,6 +33,19 @@ test('工商银行支出', () =>
'currency': 'CNY',
'time': formatDate('1月12日15:56', 'M月D日h:i'),
'channel': '工商银行[支出]'
},
{
'type': 'Expend',
'money': 5,
'fee': 0,
'shopName': '缴费财付通',
'shopItem': '北京科技大学',
'accountNameFrom': '工商银行(9301)',
'accountNameTo': '',
'currency': 'CNY',
'time': formatDate('1月18日16:00', 'M月D日h:i'),
'channel': '工商银行[支出]'
}
]));


Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"title":"动账通知","text":"尾号9301卡1月18日16:00支出(缴费财付通-北京科技大学)5元。","t":1737187216121}

0 comments on commit 656a4b9

Please sign in to comment.