diff --git a/packages/astro/src/core/app/index.ts b/packages/astro/src/core/app/index.ts index 7b7d6852d8..d06ff52806 100644 --- a/packages/astro/src/core/app/index.ts +++ b/packages/astro/src/core/app/index.ts @@ -85,7 +85,7 @@ export class App { this.#baseWithoutTrailingSlash = removeTrailingForwardSlash(this.#base); } removeBase(pathname: string) { - if(pathname.startsWith(this.#base)) { + if (pathname.startsWith(this.#base)) { return pathname.slice(this.#baseWithoutTrailingSlash.length + 1); } return pathname; diff --git a/packages/astro/src/core/build/vite-plugin-ssr.ts b/packages/astro/src/core/build/vite-plugin-ssr.ts index 6f331a72d4..33784083cb 100644 --- a/packages/astro/src/core/build/vite-plugin-ssr.ts +++ b/packages/astro/src/core/build/vite-plugin-ssr.ts @@ -10,10 +10,10 @@ import { fileURLToPath } from 'url'; import { runHookBuildSsr } from '../../integrations/index.js'; import { BEFORE_HYDRATION_SCRIPT_ID, PAGE_SCRIPT_ID } from '../../vite-plugin-scripts/index.js'; import { pagesVirtualModuleId } from '../app/index.js'; +import { removeLeadingForwardSlash, removeTrailingForwardSlash } from '../path.js'; import { serializeRouteData } from '../routing/index.js'; import { addRollupInput } from './add-rollup-input.js'; import { eachPageData, sortedCSS } from './internal.js'; -import { removeLeadingForwardSlash, removeTrailingForwardSlash } from '../path.js'; export const virtualModuleId = '@astrojs-ssr-virtual-entry'; const resolvedVirtualModuleId = '\0' + virtualModuleId; @@ -143,7 +143,7 @@ function buildManifest( } const bareBase = removeTrailingForwardSlash(removeLeadingForwardSlash(settings.config.base)); - const links = sortedCSS(pageData).map(pth => bareBase ? bareBase + '/' + pth : pth); + const links = sortedCSS(pageData).map((pth) => (bareBase ? bareBase + '/' + pth : pth)); routes.push({ file: '', diff --git a/packages/astro/test/ssr-request.test.js b/packages/astro/test/ssr-request.test.js index 15c7d27652..8f5c242a44 100644 --- a/packages/astro/test/ssr-request.test.js +++ b/packages/astro/test/ssr-request.test.js @@ -12,7 +12,7 @@ describe('Using Astro.request in SSR', () => { root: './fixtures/ssr-request/', adapter: testAdapter(), output: 'server', - base: '/subpath/' + base: '/subpath/', }); await fixture.build(); }); @@ -39,7 +39,7 @@ describe('Using Astro.request in SSR', () => { expect(response.status).to.equal(200); const html = await response.text(); const $ = cheerioLoad(html); - + const linkHref = $('link').attr('href'); expect(linkHref.startsWith('/subpath/')).to.equal(true); diff --git a/packages/integrations/node/src/preview.ts b/packages/integrations/node/src/preview.ts index 3b896cc725..b35d302049 100644 --- a/packages/integrations/node/src/preview.ts +++ b/packages/integrations/node/src/preview.ts @@ -4,7 +4,13 @@ import { fileURLToPath } from 'url'; import { createServer } from './http-server.js'; import type { createExports } from './server'; -const preview: CreatePreviewServer = async function ({ client, serverEntrypoint, host, port, base }) { +const preview: CreatePreviewServer = async function ({ + client, + serverEntrypoint, + host, + port, + base, +}) { type ServerModule = ReturnType; type MaybeServerModule = Partial; let ssrHandler: ServerModule['handler']; @@ -36,9 +42,11 @@ const preview: CreatePreviewServer = async function ({ client, serverEntrypoint, }); }; - const baseWithoutTrailingSlash: string = base.endsWith('/') ? base.slice(0, base.length - 1) : base; + const baseWithoutTrailingSlash: string = base.endsWith('/') + ? base.slice(0, base.length - 1) + : base; function removeBase(pathname: string): string { - if(pathname.startsWith(base)) { + if (pathname.startsWith(base)) { return pathname.slice(baseWithoutTrailingSlash.length); } return pathname; @@ -49,7 +57,7 @@ const preview: CreatePreviewServer = async function ({ client, serverEntrypoint, client, port, host, - removeBase + removeBase, }, handler );