From 3c80d493a69a6a124981c84b2406d1634e2f68b7 Mon Sep 17 00:00:00 2001 From: Abobo7 <2557826346@qq.com> Date: Tue, 9 Apr 2024 17:59:43 +0800 Subject: [PATCH] fix: fix several bugs of merlin --- model/merlin/index.ts | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/model/merlin/index.ts b/model/merlin/index.ts index 2c65747..e57aa25 100644 --- a/model/merlin/index.ts +++ b/model/merlin/index.ts @@ -154,22 +154,30 @@ class Child extends ComChild { req.request().method().toUpperCase() === 'GET', ); function removeRepeats(num: number): number { - const str = num.toString(); - if (str.length <= 2) { + const str = num.toString(); + const len = str.length; + + + if (len % 2 !== 0 || len === 1) { return num; } - const repeatPattern = /^(\d+?)\1+$/; - const match = str.match(repeatPattern); + const mid = len / 2; + const part1 = str.slice(0, mid); + const part2 = str.slice(mid); - if (match) { - return parseInt(match[1], 10); + + if (part1 === part2) { + return parseInt(part1, 10); } + return num; } + + const token = req.url().split('token=')[1].split('&')[0]; this.logger.info(`get login status token: ${token}`); const element = await page.$('span.text-cornblue-700'); @@ -368,4 +376,4 @@ export class Merlin extends Chat { child.destroy({ delFile: false, delMem: true }); } } -} +} \ No newline at end of file