diff --git a/server/api/registry/file/[...pkg].get.ts b/server/api/registry/file/[...pkg].get.ts
index b133e0f69d..c1dd76c1b3 100644
--- a/server/api/registry/file/[...pkg].get.ts
+++ b/server/api/registry/file/[...pkg].get.ts
@@ -6,7 +6,7 @@ import {
ERROR_PACKAGE_VERSION_AND_FILE_FAILED,
} from '#shared/utils/constants'
-const CACHE_VERSION = 2
+const CACHE_VERSION = 3
// Maximum file size to fetch and highlight (500KB)
const MAX_FILE_SIZE = 500 * 1024
diff --git a/server/utils/code-highlight.ts b/server/utils/code-highlight.ts
index 84d6a254b8..0a762eaab7 100644
--- a/server/utils/code-highlight.ts
+++ b/server/utils/code-highlight.ts
@@ -220,11 +220,20 @@ function linkifyImports(html: string, options?: LinkifyOptions): string {
// or: import('module'
// Note: require often has a leading space in the span from Shiki
result = result.replace(
- /(]*>)\s*(require|import)(<\/span>)(]*>\(<\/span>)(]*>)(['"][^'"]+['"])<\/span>/g,
- (match, spanOpen, keyword, spanClose, parenSpan, stringSpanOpen, moduleSpecifier) => {
+ /(]*>)(\s*)(require|import)(<\/span>)(]*>\(<\/span>)(]*>)(['"][^'"]+['"])<\/span>/g,
+ (
+ match,
+ spanOpen,
+ whitespace,
+ keyword,
+ spanClose,
+ parenSpan,
+ stringSpanOpen,
+ moduleSpecifier,
+ ) => {
const href = getHref(moduleSpecifier)
if (!href) return match
- return `${spanOpen}${keyword}${spanClose}${parenSpan}${stringSpanOpen}${moduleSpecifier}`
+ return `${spanOpen}${whitespace}${keyword}${spanClose}${parenSpan}${stringSpanOpen}${moduleSpecifier}`
},
)