From 69c44fd9065f2e9212093ece603b1ad2cb8024fe Mon Sep 17 00:00:00 2001 From: shichao <834466168@qq.com> Date: Thu, 2 Jan 2025 16:10:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=BD=93str=E4=B8=8D?= =?UTF-8?q?=E4=B8=BAstring=E6=97=B6,=20=E5=AF=BC=E8=87=B4includes=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E4=B8=8D=E5=AD=98=E5=9C=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dynamic-import-to-glob.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/dynamic-import-to-glob.ts b/src/dynamic-import-to-glob.ts index c992784..90db679 100644 --- a/src/dynamic-import-to-glob.ts +++ b/src/dynamic-import-to-glob.ts @@ -2,11 +2,15 @@ import path from 'node:path' const example = 'For example: import(`./foo/${bar}.js`).' -function sanitizeString(str: string) { - if (str.includes('*')) { - throw new Error('A dynamic import cannot contain * characters.') +function sanitizeString(str: any) { + if(typeof str === "string" ){ + if (str.includes('*')) { + throw new Error('A dynamic import cannot contain * characters.') + } + return str + } else { + return "*" } - return str } function templateLiteralToGlob(node: AcornNode) {