From 5c20476fd333d57c583777893e8c6196b4764d1f Mon Sep 17 00:00:00 2001 From: matthewp Date: Fri, 9 Jun 2023 04:56:15 +0000 Subject: [PATCH] [ci] format --- packages/astro/src/core/endpoint/index.ts | 6 +++++- packages/astro/src/prerender/routing.ts | 12 ++++++++---- packages/astro/test/redirects.test.js | 18 +++++++++--------- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/packages/astro/src/core/endpoint/index.ts b/packages/astro/src/core/endpoint/index.ts index 71a21850b8ab..5822685cf987 100644 --- a/packages/astro/src/core/endpoint/index.ts +++ b/packages/astro/src/core/endpoint/index.ts @@ -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); } } diff --git a/packages/astro/src/prerender/routing.ts b/packages/astro/src/prerender/routing.ts index 3c0e1f8a4f9d..fc01b0480d3f 100644 --- a/packages/astro/src/prerender/routing.ts +++ b/packages/astro/src/prerender/routing.ts @@ -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, }; } diff --git a/packages/astro/test/redirects.test.js b/packages/astro/test/redirects.test.js index 2e1e0b8b97e4..6cbf0fdfc0fe 100644 --- a/packages/astro/test/redirects.test.js +++ b/packages/astro/test/redirects.test.js @@ -86,37 +86,37 @@ describe('Astro.redirect', () => { }); await fixture.build(); }); - + it('Includes the meta refresh tag in Astro.redirect pages', async () => { const html = await fixture.readFile('/secret/index.html'); expect(html).to.include('http-equiv="refresh'); expect(html).to.include('url=/login'); }); - + it('Includes the meta refresh tag in `redirect` config pages', async () => { let html = await fixture.readFile('/one/index.html'); expect(html).to.include('http-equiv="refresh'); expect(html).to.include('url=/'); - + html = await fixture.readFile('/two/index.html'); expect(html).to.include('http-equiv="refresh'); expect(html).to.include('url=/'); - + html = await fixture.readFile('/three/index.html'); expect(html).to.include('http-equiv="refresh'); expect(html).to.include('url=/'); }); - + it('Generates page for dynamic routes', async () => { let html = await fixture.readFile('/blog/one/index.html'); expect(html).to.include('http-equiv="refresh'); expect(html).to.include('url=/articles/one'); - + html = await fixture.readFile('/blog/two/index.html'); expect(html).to.include('http-equiv="refresh'); expect(html).to.include('url=/articles/two'); }); - + it('Generates redirect pages for redirects created by middleware', async () => { let html = await fixture.readFile('/middleware-redirect/index.html'); expect(html).to.include('http-equiv="refresh'); @@ -145,10 +145,10 @@ describe('Astro.redirect', () => { after(async () => { await devServer.stop(); }); - + it('Returns 301', async () => { let res = await fixture.fetch('/one', { - redirect: 'manual' + redirect: 'manual', }); expect(res.status).to.equal(301); });