[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);
|
this.#baseWithoutTrailingSlash = removeTrailingForwardSlash(this.#base);
|
||||||
}
|
}
|
||||||
removeBase(pathname: string) {
|
removeBase(pathname: string) {
|
||||||
if(pathname.startsWith(this.#base)) {
|
if (pathname.startsWith(this.#base)) {
|
||||||
return pathname.slice(this.#baseWithoutTrailingSlash.length + 1);
|
return pathname.slice(this.#baseWithoutTrailingSlash.length + 1);
|
||||||
}
|
}
|
||||||
return pathname;
|
return pathname;
|
||||||
|
|
|
@ -10,10 +10,10 @@ import { fileURLToPath } from 'url';
|
||||||
import { runHookBuildSsr } from '../../integrations/index.js';
|
import { runHookBuildSsr } from '../../integrations/index.js';
|
||||||
import { BEFORE_HYDRATION_SCRIPT_ID, PAGE_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
|
import { BEFORE_HYDRATION_SCRIPT_ID, PAGE_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
|
||||||
import { pagesVirtualModuleId } from '../app/index.js';
|
import { pagesVirtualModuleId } from '../app/index.js';
|
||||||
|
import { removeLeadingForwardSlash, removeTrailingForwardSlash } from '../path.js';
|
||||||
import { serializeRouteData } from '../routing/index.js';
|
import { serializeRouteData } from '../routing/index.js';
|
||||||
import { addRollupInput } from './add-rollup-input.js';
|
import { addRollupInput } from './add-rollup-input.js';
|
||||||
import { eachPageData, sortedCSS } from './internal.js';
|
import { eachPageData, sortedCSS } from './internal.js';
|
||||||
import { removeLeadingForwardSlash, removeTrailingForwardSlash } from '../path.js';
|
|
||||||
|
|
||||||
export const virtualModuleId = '@astrojs-ssr-virtual-entry';
|
export const virtualModuleId = '@astrojs-ssr-virtual-entry';
|
||||||
const resolvedVirtualModuleId = '\0' + virtualModuleId;
|
const resolvedVirtualModuleId = '\0' + virtualModuleId;
|
||||||
|
@ -143,7 +143,7 @@ function buildManifest(
|
||||||
}
|
}
|
||||||
|
|
||||||
const bareBase = removeTrailingForwardSlash(removeLeadingForwardSlash(settings.config.base));
|
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({
|
routes.push({
|
||||||
file: '',
|
file: '',
|
||||||
|
|
|
@ -12,7 +12,7 @@ describe('Using Astro.request in SSR', () => {
|
||||||
root: './fixtures/ssr-request/',
|
root: './fixtures/ssr-request/',
|
||||||
adapter: testAdapter(),
|
adapter: testAdapter(),
|
||||||
output: 'server',
|
output: 'server',
|
||||||
base: '/subpath/'
|
base: '/subpath/',
|
||||||
});
|
});
|
||||||
await fixture.build();
|
await fixture.build();
|
||||||
});
|
});
|
||||||
|
@ -39,7 +39,7 @@ describe('Using Astro.request in SSR', () => {
|
||||||
expect(response.status).to.equal(200);
|
expect(response.status).to.equal(200);
|
||||||
const html = await response.text();
|
const html = await response.text();
|
||||||
const $ = cheerioLoad(html);
|
const $ = cheerioLoad(html);
|
||||||
|
|
||||||
const linkHref = $('link').attr('href');
|
const linkHref = $('link').attr('href');
|
||||||
expect(linkHref.startsWith('/subpath/')).to.equal(true);
|
expect(linkHref.startsWith('/subpath/')).to.equal(true);
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,13 @@ import { fileURLToPath } from 'url';
|
||||||
import { createServer } from './http-server.js';
|
import { createServer } from './http-server.js';
|
||||||
import type { createExports } from './server';
|
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 ServerModule = ReturnType<typeof createExports>;
|
||||||
type MaybeServerModule = Partial<ServerModule>;
|
type MaybeServerModule = Partial<ServerModule>;
|
||||||
let ssrHandler: ServerModule['handler'];
|
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 {
|
function removeBase(pathname: string): string {
|
||||||
if(pathname.startsWith(base)) {
|
if (pathname.startsWith(base)) {
|
||||||
return pathname.slice(baseWithoutTrailingSlash.length);
|
return pathname.slice(baseWithoutTrailingSlash.length);
|
||||||
}
|
}
|
||||||
return pathname;
|
return pathname;
|
||||||
|
@ -49,7 +57,7 @@ const preview: CreatePreviewServer = async function ({ client, serverEntrypoint,
|
||||||
client,
|
client,
|
||||||
port,
|
port,
|
||||||
host,
|
host,
|
||||||
removeBase
|
removeBase,
|
||||||
},
|
},
|
||||||
handler
|
handler
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue