[ci] yarn format

This commit is contained in:
matthewp 2022-01-06 21:34:01 +00:00 committed by GitHub Actions
parent 4aa395c75e
commit 778adc662a
4 changed files with 54 additions and 54 deletions

View file

@ -1,4 +1,3 @@
export function appendForwardSlash(path: string) {
return path.endsWith('/') ? path : path + '/';
}

View file

@ -12,7 +12,6 @@ import { prependForwardSlash } from '../path.js';
import * as npath from 'path';
import * as fs from 'fs';
interface PreviewOptions {
logging: LogOptions;
}
@ -51,11 +50,13 @@ export default async function preview(config: AstroConfig, { logging }: PreviewO
case 'always': {
if (!req.url?.endsWith('/')) {
res.statusCode = 404;
res.end(template({
res.end(
template({
title: 'Not found',
tabTitle: 'Not found',
pathname: req.url!,
}));
})
);
return;
}
break;
@ -63,11 +64,13 @@ export default async function preview(config: AstroConfig, { logging }: PreviewO
case 'never': {
if (req.url?.endsWith('/')) {
res.statusCode = 404;
res.end(template({
res.end(
template({
title: 'Not found',
tabTitle: 'Not found',
pathname: req.url!,
}));
})
);
return;
}
break;
@ -79,7 +82,7 @@ export default async function preview(config: AstroConfig, { logging }: PreviewO
let sendpath = removeBase(base, req.url!);
const sendOptions: send.SendOptions = {
root: fileURLToPath(config.dist)
root: fileURLToPath(config.dist),
};
if (config.buildOptions.pageUrlFormat === 'file' && !sendpath.endsWith('.html')) {
sendOptions.index = false;

View file

@ -80,8 +80,7 @@ export function rollupPluginAstroBuildHTML(options: PluginOptions): VitePlugin {
}
for (const pathname of pageData.paths) {
const pathrepl = astroConfig.buildOptions.pageUrlFormat === 'directory' ?
'/index.html' : pathname === '/' ? 'index.html' : '.html';
const pathrepl = astroConfig.buildOptions.pageUrlFormat === 'directory' ? '/index.html' : pathname === '/' ? 'index.html' : '.html';
pageNames.push(pathname.replace(/\/?$/, pathrepl).replace(/^\//, ''));
const id = ASTRO_PAGE_PREFIX + pathname;
const html = await ssrRender(renderers, mod, {

View file

@ -14,8 +14,8 @@ describe('Preview Routing', () => {
projectRoot: './fixtures/with-subpath-no-trailing-slash/',
devOptions: {
trailingSlash: 'never',
port: 4000
}
port: 4000,
},
});
await fixture.build();
previewServer = await fixture.preview();
@ -68,8 +68,8 @@ describe('Preview Routing', () => {
projectRoot: './fixtures/with-subpath-no-trailing-slash/',
devOptions: {
trailingSlash: 'always',
port: 4001
}
port: 4001,
},
});
await fixture.build();
previewServer = await fixture.preview();
@ -127,8 +127,8 @@ describe('Preview Routing', () => {
projectRoot: './fixtures/with-subpath-no-trailing-slash/',
devOptions: {
trailingSlash: 'ignore',
port: 4002
}
port: 4002,
},
});
await fixture.build();
previewServer = await fixture.preview();
@ -187,12 +187,12 @@ describe('Preview Routing', () => {
fixture = await loadFixture({
projectRoot: './fixtures/with-subpath-no-trailing-slash/',
buildOptions: {
pageUrlFormat: 'file'
pageUrlFormat: 'file',
},
devOptions: {
trailingSlash: 'never',
port: 4003
}
port: 4003,
},
});
await fixture.build();
previewServer = await fixture.preview();
@ -244,12 +244,12 @@ describe('Preview Routing', () => {
fixture = await loadFixture({
projectRoot: './fixtures/with-subpath-no-trailing-slash/',
buildOptions: {
pageUrlFormat: 'file'
pageUrlFormat: 'file',
},
devOptions: {
trailingSlash: 'always',
port: 4004
}
port: 4004,
},
});
await fixture.build();
previewServer = await fixture.preview();
@ -306,12 +306,12 @@ describe('Preview Routing', () => {
fixture = await loadFixture({
projectRoot: './fixtures/with-subpath-no-trailing-slash/',
buildOptions: {
pageUrlFormat: 'file'
pageUrlFormat: 'file',
},
devOptions: {
trailingSlash: 'ignore',
port: 4005
}
port: 4005,
},
});
await fixture.build();
previewServer = await fixture.preview();
@ -368,12 +368,12 @@ describe('Preview Routing', () => {
fixture = await loadFixture({
projectRoot: './fixtures/with-subpath-no-trailing-slash/',
buildOptions: {
pageUrlFormat: 'file'
pageUrlFormat: 'file',
},
devOptions: {
trailingSlash: 'ignore',
port: 4006
}
port: 4006,
},
});
await fixture.build();
previewServer = await fixture.preview();
@ -398,7 +398,6 @@ describe('Preview Routing', () => {
expect(response.status).to.equal(200);
});
it('200 when loading dynamic route', async () => {
const response = await fixture.fetch('/blog/1.html');
expect(response.status).to.equal(200);