mirror of
https://github.com/withastro/astro.git
synced 2025-03-31 23:31:30 -05:00
[ci] format
This commit is contained in:
parent
536175528d
commit
18a2699f53
10 changed files with 22 additions and 22 deletions
|
@ -1 +1 @@
|
|||
@import "tailwindcss";
|
||||
@import 'tailwindcss';
|
||||
|
|
|
@ -100,4 +100,3 @@ export const SUPPORTED_MARKDOWN_FILE_EXTENSIONS = [
|
|||
|
||||
// The folder name where to find the middleware
|
||||
export const MIDDLEWARE_PATH_SEGMENT_NAME = 'middleware';
|
||||
|
||||
|
|
|
@ -130,7 +130,10 @@ export function subpathNotUsedTemplate(base: string, pathname: string) {
|
|||
});
|
||||
}
|
||||
|
||||
export function trailingSlashMismatchTemplate(pathname: string, trailingSlash: 'always' | 'never' | 'ignore') {
|
||||
export function trailingSlashMismatchTemplate(
|
||||
pathname: string,
|
||||
trailingSlash: 'always' | 'never' | 'ignore',
|
||||
) {
|
||||
const corrected =
|
||||
trailingSlash === 'always'
|
||||
? appendForwardSlash(pathname)
|
||||
|
|
|
@ -242,7 +242,7 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
|
|||
* - `'never'` - Only match URLs that do not include a trailing slash (e.g: "/about"). In production, requests for on-demand rendered URLs with a trailing slash will be redirected to the correct URL for your convenience. However, in development, they will display a warning page reminding you that you have `never` configured.
|
||||
*
|
||||
* When redirects occur in production for GET requests, the redirect will be a 301 (permanent) redirect. For all other request methods, it will be a 308 (permanent, and preserve the request method) redirect.
|
||||
*
|
||||
*
|
||||
* Trailing slashes on prerendered pages are handled by the hosting platform, and may not respect your chosen configuration.
|
||||
* See your hosting platform's documentation for more information.
|
||||
*
|
||||
|
|
|
@ -3,11 +3,11 @@ import type { AstroSettings } from '../types/astro.js';
|
|||
|
||||
import * as fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { appendForwardSlash } from '@astrojs/internal-helpers/path';
|
||||
import { bold } from 'kleur/colors';
|
||||
import type { Logger } from '../core/logger/core.js';
|
||||
import { notFoundTemplate, subpathNotUsedTemplate } from '../template/4xx.js';
|
||||
import { writeHtmlResponse } from './response.js';
|
||||
import { appendForwardSlash } from '@astrojs/internal-helpers/path';
|
||||
|
||||
export function baseMiddleware(
|
||||
settings: AstroSettings,
|
||||
|
|
|
@ -3,8 +3,8 @@ import { after, before, describe, it } from 'node:test';
|
|||
import * as cheerio from 'cheerio';
|
||||
import { ServerOnlyModule } from '../dist/core/errors/errors-data.js';
|
||||
import { AstroError } from '../dist/core/errors/index.js';
|
||||
import testAdapter from './test-adapter.js';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
import testAdapter from "./test-adapter.js";
|
||||
|
||||
describe('astro:manifest/client', () => {
|
||||
/** @type {import('./test-utils').Fixture} */
|
||||
|
@ -110,14 +110,13 @@ describe('astro:manifest/client', () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('astro:manifest/server', () => {
|
||||
/** @type {import('./test-utils').Fixture} */
|
||||
let fixture;
|
||||
let devServer;
|
||||
let app
|
||||
let app;
|
||||
|
||||
describe('when build', () => {
|
||||
before(async () => {
|
||||
|
@ -132,7 +131,6 @@ describe('astro:manifest/server', () => {
|
|||
assert.equal(error.name, ServerOnlyModule.name);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('when the experimental flag is not enabled in dev', async () => {
|
||||
before(async () => {
|
||||
|
@ -211,12 +209,11 @@ describe('astro:manifest/server', () => {
|
|||
adapter: testAdapter(),
|
||||
output: 'server',
|
||||
});
|
||||
|
||||
|
||||
await fixture.build();
|
||||
app = await fixture.loadTestAdapterApp();
|
||||
});
|
||||
|
||||
|
||||
it('should return the expected properties', async () => {
|
||||
const request = new Request('http://example.com/server');
|
||||
const response = await app.render(request);
|
||||
|
|
|
@ -85,14 +85,14 @@ describe('Redirecting trailing slashes in SSR', () => {
|
|||
assert.equal(response.headers.get('Location'), '/dot.in.directory/path/');
|
||||
});
|
||||
|
||||
it("Does not redirect internal paths", async () => {
|
||||
it('Does not redirect internal paths', async () => {
|
||||
const app = await fixture.loadTestAdapterApp();
|
||||
|
||||
for (const path of [
|
||||
'/_astro/something',
|
||||
'/_image?url=http://example.com/foo.jpg',
|
||||
'/_server-islands/foo',
|
||||
'/_actions/foo'
|
||||
'/_actions/foo',
|
||||
]) {
|
||||
const request = new Request(`http://example.com${path}`);
|
||||
const response = await app.render(request);
|
||||
|
@ -100,14 +100,13 @@ describe('Redirecting trailing slashes in SSR', () => {
|
|||
}
|
||||
});
|
||||
|
||||
it("Redirects POST requests", async () => {
|
||||
it('Redirects POST requests', async () => {
|
||||
const app = await fixture.loadTestAdapterApp();
|
||||
const request = new Request('http://example.com/another', { method: 'POST' });
|
||||
const response = await app.render(request);
|
||||
assert.equal(response.status, 308);
|
||||
assert.equal(response.headers.get('Location'), '/another/');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('trailingSlash: never', () => {
|
||||
|
@ -189,7 +188,7 @@ describe('Redirecting trailing slashes in SSR', () => {
|
|||
'/_astro/something/',
|
||||
'/_image/?url=http://example.com/foo.jpg',
|
||||
'/_server-islands/foo/',
|
||||
'/_actions/foo/'
|
||||
'/_actions/foo/',
|
||||
]) {
|
||||
const request = new Request(`http://example.com${path}/`);
|
||||
const response = await app.render(request);
|
||||
|
@ -204,7 +203,6 @@ describe('Redirecting trailing slashes in SSR', () => {
|
|||
assert.equal(response.status, 308);
|
||||
assert.equal(response.headers.get('Location'), '/another');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('trailingSlash: ignore', () => {
|
||||
|
@ -218,7 +216,7 @@ describe('Redirecting trailing slashes in SSR', () => {
|
|||
await fixture.build();
|
||||
});
|
||||
|
||||
it("Redirects to collapse multiple trailing slashes", async () => {
|
||||
it('Redirects to collapse multiple trailing slashes', async () => {
|
||||
const app = await fixture.loadTestAdapterApp();
|
||||
const request = new Request('http://example.com/another///');
|
||||
const response = await app.render(request);
|
||||
|
|
|
@ -78,7 +78,7 @@ export function toPromise(res) {
|
|||
if (ArrayBuffer.isView(data) && !Buffer.isBuffer(data)) {
|
||||
data = Buffer.from(data.buffer);
|
||||
}
|
||||
if(typeof data === 'string') {
|
||||
if (typeof data === 'string') {
|
||||
data = Buffer.from(data);
|
||||
}
|
||||
return write.call(this, data, encoding);
|
||||
|
|
|
@ -22,8 +22,8 @@ export function collapseDuplicateSlashes(path: string) {
|
|||
export const MANY_TRAILING_SLASHES = /\/{2,}/g;
|
||||
|
||||
export function collapseDuplicateTrailingSlashes(path: string, trailingSlash: boolean) {
|
||||
if(!path) {
|
||||
return path
|
||||
if (!path) {
|
||||
return path;
|
||||
}
|
||||
return path.replace(MANY_TRAILING_SLASHES, trailingSlash ? '/' : '') || '/';
|
||||
}
|
||||
|
|
|
@ -71,7 +71,10 @@ export function parseFrontmatter(
|
|||
);
|
||||
break;
|
||||
case 'empty-with-lines':
|
||||
content = code.replace(`${delims}${rawFrontmatter}${delims}`, rawFrontmatter.replace(/[^\r\n]/g, ''));
|
||||
content = code.replace(
|
||||
`${delims}${rawFrontmatter}${delims}`,
|
||||
rawFrontmatter.replace(/[^\r\n]/g, ''),
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue