mirror of
https://github.com/withastro/astro.git
synced 2024-12-23 21:53:55 -05:00
[ci] format
This commit is contained in:
parent
b2b291d291
commit
a10cbec67e
4 changed files with 17 additions and 9 deletions
|
@ -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;
|
||||
|
|
|
@ -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: '',
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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<typeof createExports>;
|
||||
type MaybeServerModule = Partial<ServerModule>;
|
||||
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
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue