From fd360641d48a29bd02f69a331f5b296abcfca8b9 Mon Sep 17 00:00:00 2001 From: haxibami Date: Thu, 20 Jun 2024 18:00:15 +0900 Subject: [PATCH] declare base once per route --- src/lib/CopyAssetIntegration.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib/CopyAssetIntegration.ts b/src/lib/CopyAssetIntegration.ts index ccf3b9adf7..c13d595cd2 100644 --- a/src/lib/CopyAssetIntegration.ts +++ b/src/lib/CopyAssetIntegration.ts @@ -34,11 +34,12 @@ export default function CopyAssetIntegration(): AstroIntegration { const source = await read(path); const hast = parser.parse(source); + const base = new URL( + join(relative("src/pages", dirname(component)), sep), + ORIGINS[0], + ); + for (const tag of selectAll("a", hast)) { - const base = new URL( - join(relative("src/pages", dirname(component)), sep), - ORIGINS[0], - ); const href = tag.properties?.href; if (typeof href !== "string") continue; const absoluteUrl = new URL(href, base);