diff --git a/packages/astro/src/vite-plugin-markdown/images.ts b/packages/astro/src/vite-plugin-markdown/images.ts index 66ec141067e9..1488ef6fc8c4 100644 --- a/packages/astro/src/vite-plugin-markdown/images.ts +++ b/packages/astro/src/vite-plugin-markdown/images.ts @@ -13,7 +13,10 @@ export function getMarkdownCodeForImages(imagePaths: MarkdownImagePath[], html: .map((entry) => { const rawUrl = JSON.stringify(entry.raw); return `{ - const regex = new RegExp('__ASTRO_IMAGE_="([^"]*' + ${rawUrl.replace(/[.*+?^${}()|[\]\\]/g, '\\\\$&')} + '[^"]*)"', 'g'); + const regex = new RegExp('__ASTRO_IMAGE_="([^"]*' + ${rawUrl.replace( + /[.*+?^${}()|[\]\\]/g, + '\\\\$&' + )} + '[^"]*)"', 'g'); let match; let occurrenceCounter = 0; while ((match = regex.exec(html)) !== null) {