mirror of
https://github.com/withastro/astro.git
synced 2025-02-17 22:44:24 -05:00
[ci] format
This commit is contained in:
parent
bbcf69e7b8
commit
5c20476fd3
3 changed files with 22 additions and 14 deletions
|
@ -161,7 +161,11 @@ function isRedirect(statusCode: number) {
|
|||
}
|
||||
|
||||
export function throwIfRedirectNotAllowed(response: Response, config: AstroConfig) {
|
||||
if (!isServerLikeOutput(config) && isRedirect(response.status) && !config.experimental.redirects) {
|
||||
if (
|
||||
!isServerLikeOutput(config) &&
|
||||
isRedirect(response.status) &&
|
||||
!config.experimental.redirects
|
||||
) {
|
||||
throw new AstroError(AstroErrorData.StaticRedirectNotAvailable);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
import type { AstroSettings, RouteData } from '../@types/astro';
|
||||
import { preload, type DevelopmentEnvironment, type ComponentPreload } from '../core/render/dev/index.js';
|
||||
import { RedirectComponentInstance, routeIsRedirect } from '../core/redirects/index.js';
|
||||
import {
|
||||
preload,
|
||||
type ComponentPreload,
|
||||
type DevelopmentEnvironment,
|
||||
} from '../core/render/dev/index.js';
|
||||
import { getPrerenderStatus } from './metadata.js';
|
||||
import { routeIsRedirect, RedirectComponentInstance } from '../core/redirects/index.js';
|
||||
|
||||
type GetSortedPreloadedMatchesParams = {
|
||||
env: DevelopmentEnvironment;
|
||||
|
@ -43,12 +47,12 @@ async function preloadAndSetPrerenderStatus({
|
|||
matches.map(async (route) => {
|
||||
const filePath = new URL(`./${route.component}`, settings.config.root);
|
||||
|
||||
if(routeIsRedirect(route)) {
|
||||
if (routeIsRedirect(route)) {
|
||||
const preloadedComponent: ComponentPreload = [[], RedirectComponentInstance];
|
||||
return {
|
||||
preloadedComponent,
|
||||
route,
|
||||
filePath
|
||||
filePath,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ describe('Astro.redirect', () => {
|
|||
|
||||
it('Returns 301', async () => {
|
||||
let res = await fixture.fetch('/one', {
|
||||
redirect: 'manual'
|
||||
redirect: 'manual',
|
||||
});
|
||||
expect(res.status).to.equal(301);
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue