From 8685da1651a08dad022770e1297e2e24cf970f21 Mon Sep 17 00:00:00 2001 From: ice Date: Sun, 11 May 2025 02:22:16 +0800 Subject: [PATCH] fix: update HTML title regex to support attributes and change TypeScript target to ES2018 --- src/lib/htmlHelper.ts | 2 +- tsconfig.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/htmlHelper.ts b/src/lib/htmlHelper.ts index 4cf9713..9711673 100644 --- a/src/lib/htmlHelper.ts +++ b/src/lib/htmlHelper.ts @@ -243,7 +243,7 @@ const htmlEntityMapping = new Map([ const htmlEntityRegExp = new RegExp(`&(#\\d+|#x[\\da-fA-F]+|${Array.from(htmlEntityMapping.keys()).join('|')});`, 'gi'); export function getTitle(html: string): string|null { - const matches = html.match(/(?<=\).*?(?=\<\/title\>)/si); + const matches = html.match(/(?<=\]*\>).*?(?=\<\/title\>)/si); if (!matches) { return null; } diff --git a/tsconfig.json b/tsconfig.json index b65c745..7582467 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,10 @@ { "compilerOptions": { "module": "commonjs", - "target": "es6", + "target": "es2018", "outDir": "out", "lib": [ - "es6" + "es2018" ], "sourceMap": true, "rootDir": "src",