From 9741f5eb1eff63c9695ea504892ba6d9414b8299 Mon Sep 17 00:00:00 2001 From: "N. V. Lang" Date: Wed, 17 Jul 2024 23:24:23 +0200 Subject: [PATCH] fix: reduce false positives of `isImported` fn --- src/utils/markdown.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/markdown.ts b/src/utils/markdown.ts index 1d34b3e..3eae1b0 100644 --- a/src/utils/markdown.ts +++ b/src/utils/markdown.ts @@ -238,7 +238,8 @@ export function isImported( componentInfo: { name: string; importPath: string }, ): boolean { return new RegExp( - `import\\s*(?:\\s${componentInfo.name}\\s|\\{\\s*default as ${componentInfo.name}\\s*\\})\\s*from\\s*['"]`, + `^\\s*import\\s*(?:\\s${componentInfo.name}\\s|\\{\\s*default as ${componentInfo.name}\\s*\\})\\s*from\\s*['"]`, + 'm', ).test(script); }