diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts index 4bac5ae29..e76d51ca3 100644 --- a/packages/astro/src/core/build/generate.ts +++ b/packages/astro/src/core/build/generate.ts @@ -178,9 +178,10 @@ async function generatePath( // If a base path was provided, append it to the site URL. This ensures that // all injected scripts and links are referenced relative to the site and subpath. - const site = astroConfig.base && astroConfig.base !== './' - ? joinPaths(astroConfig.site?.toString() || 'http://localhost/', astroConfig.base) - : astroConfig.site; + const site = + astroConfig.base && astroConfig.base !== './' + ? joinPaths(astroConfig.site?.toString() || 'http://localhost/', astroConfig.base) + : astroConfig.site; const links = createLinkStylesheetElementSet(linkIds.reverse(), site); const scripts = createModuleScriptElementWithSrcSet(hoistedId ? [hoistedId] : [], site); diff --git a/packages/astro/src/core/path.ts b/packages/astro/src/core/path.ts index e499c8c5a..427ce23c6 100644 --- a/packages/astro/src/core/path.ts +++ b/packages/astro/src/core/path.ts @@ -45,4 +45,4 @@ function isString(path: unknown): path is string { export function joinPaths(...paths: (string | undefined)[]) { return paths.filter(isString).map(trimSlashes).join('/'); -} \ No newline at end of file +} diff --git a/packages/astro/src/vite-plugin-astro-server/index.ts b/packages/astro/src/vite-plugin-astro-server/index.ts index 3d8529fee..d21fa7e8e 100644 --- a/packages/astro/src/vite-plugin-astro-server/index.ts +++ b/packages/astro/src/vite-plugin-astro-server/index.ts @@ -112,11 +112,12 @@ async function handle404Response( html = subpathNotUsedTemplate(devRoot, pathname); } else { // HACK: redirect without the base path for assets in publicDir - const redirectTo = - req.method === 'GET' - && config.base && config.base !== './' - && pathname.startsWith(config.base) - && pathname.replace(config.base, '/'); + const redirectTo = + req.method === 'GET' && + config.base && + config.base !== './' && + pathname.startsWith(config.base) && + pathname.replace(config.base, '/'); if (redirectTo && redirectTo !== '/') { const response = new Response(null, { diff --git a/packages/astro/test/static-build.test.js b/packages/astro/test/static-build.test.js index b2c9d9d47..a461209a2 100644 --- a/packages/astro/test/static-build.test.js +++ b/packages/astro/test/static-build.test.js @@ -8,7 +8,7 @@ function addLeadingSlash(path) { function removeBasePath(path) { // `/subpath` is defined in the test fixture's Astro config - return path.replace('/subpath', '') + return path.replace('/subpath', ''); } /**