From 1849c5a0c63593ddf2dd759d88735236f35c90a6 Mon Sep 17 00:00:00 2001 From: Neal <1107554021@qq.com> Date: Tue, 10 Dec 2024 12:26:30 +0800 Subject: [PATCH] fix: only eip number return null --- src/app.service.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/app.service.ts b/src/app.service.ts index 9105052..d7aeadb 100644 --- a/src/app.service.ts +++ b/src/app.service.ts @@ -83,12 +83,11 @@ export class AppService { try { const result = {}; // eip match - const numbers = content.match(/\d+/g); - const texts = content.match(/\D+/g); + const numbers = content.match(/\d+/g) || []; + const texts = content.match(/\D+/g) || []; const txt = texts.length ? texts.join(' ').trim() : ''; const eips = []; let eipCondition = ''; - console.log(numbers); if (numbers && numbers.length) { numbers.forEach((item) => { if (Number(item) < 10000) { @@ -103,7 +102,7 @@ export class AppService { } } - if (eips.length && !txt) { + if (eips?.length && !txt) { const eipRecords = await this.connection.query( `SELECT eip, title, type, category FROM "EIPs" WHERE ${eipCondition}`, );