From 4ce2ba972aefb88e5e82cb3076f7db9c026b4881 Mon Sep 17 00:00:00 2001 From: matthewp Date: Thu, 13 Jul 2023 20:12:07 +0000 Subject: [PATCH] [ci] format --- packages/astro/src/core/build/static-build.ts | 4 ++-- .../astro/src/core/routing/manifest/create.ts | 8 ++++---- packages/astro/test/redirects.test.js | 4 ++-- .../astro/test/units/routing/manifest.test.js | 19 +++++++++++-------- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts index 2de49c487..6065a5007 100644 --- a/packages/astro/src/core/build/static-build.ts +++ b/packages/astro/src/core/build/static-build.ts @@ -21,6 +21,7 @@ import { isServerLikeOutput } from '../../prerender/utils.js'; import { PAGE_SCRIPT_ID } from '../../vite-plugin-scripts/index.js'; import { AstroError, AstroErrorData } from '../errors/index.js'; import { info } from '../logger/core.js'; +import { routeIsRedirect } from '../redirects/index.js'; import { getOutDirWithinCwd } from './common.js'; import { generatePages } from './generate.js'; import { trackPageData } from './internal.js'; @@ -32,7 +33,6 @@ import { RESOLVED_SPLIT_MODULE_ID, SSR_VIRTUAL_MODULE_ID } from './plugins/plugi import { ASTRO_PAGE_EXTENSION_POST_PATTERN } from './plugins/util.js'; import type { PageBuildData, StaticBuildOptions } from './types'; import { getTimeStat } from './util.js'; -import { routeIsRedirect } from '../redirects/index.js'; export async function viteBuild(opts: StaticBuildOptions) { const { allPages, settings } = opts; @@ -61,7 +61,7 @@ export async function viteBuild(opts: StaticBuildOptions) { // Track the page data in internals trackPageData(internals, component, pageData, astroModuleId, astroModuleURL); - if(!routeIsRedirect(pageData.route)) { + if (!routeIsRedirect(pageData.route)) { pageInput.add(astroModuleId); facadeIdToPageDataMap.set(fileURLToPath(astroModuleURL), pageData); } diff --git a/packages/astro/src/core/routing/manifest/create.ts b/packages/astro/src/core/routing/manifest/create.ts index bb0fa4ba3..70a59be59 100644 --- a/packages/astro/src/core/routing/manifest/create.ts +++ b/packages/astro/src/core/routing/manifest/create.ts @@ -463,16 +463,16 @@ export function createRouteManifest( const redirBase = path.posix.dirname(route); const dynamicRedir = lastSegmentIsDynamic(routeData); let i = 0; - for(const existingRoute of routes) { + for (const existingRoute of routes) { // An exact match, prefer the page/endpoint. This matches hosts. - if(existingRoute.route === route) { - routes.splice(i+1, 0, routeData); + if (existingRoute.route === route) { + routes.splice(i + 1, 0, routeData); return; } // If the existing route is dynamic, prefer the static redirect. const base = path.posix.dirname(existingRoute.route); - if(base === redirBase && !dynamicRedir && lastSegmentIsDynamic(existingRoute)) { + if (base === redirBase && !dynamicRedir && lastSegmentIsDynamic(existingRoute)) { routes.splice(i, 0, routeData); return; } diff --git a/packages/astro/test/redirects.test.js b/packages/astro/test/redirects.test.js index 91ec19dfa..3f017275a 100644 --- a/packages/astro/test/redirects.test.js +++ b/packages/astro/test/redirects.test.js @@ -109,13 +109,13 @@ describe('Astro.redirect', () => { const html = await fixture.readFile('/secret/index.html'); expect(html).to.include(''); }); - + it('A 302 status generates a "temporary redirect" through a short delay', async () => { // https://developers.google.com/search/docs/crawling-indexing/301-redirects#metarefresh const html = await fixture.readFile('/secret/index.html'); expect(html).to.include('content="2;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'); diff --git a/packages/astro/test/units/routing/manifest.test.js b/packages/astro/test/units/routing/manifest.test.js index 94ed3eb8a..c845fc4bb 100644 --- a/packages/astro/test/units/routing/manifest.test.js +++ b/packages/astro/test/units/routing/manifest.test.js @@ -66,7 +66,7 @@ describe('routing - createRouteManifest', () => { it('static redirect route is prioritized over dynamic file route', async () => { const fs = createFs( { - '/src/pages/[...slug].astro': `

test

` + '/src/pages/[...slug].astro': `

test

`, }, root ); @@ -74,16 +74,19 @@ describe('routing - createRouteManifest', () => { { trailingSlash: 'never', redirects: { - '/foo': '/bar' - } + '/foo': '/bar', + }, }, root ); - const manifest = createRouteManifest({ - cwd: fileURLToPath(root), - settings, - fsMod: fs, - }, defaultLogging); + const manifest = createRouteManifest( + { + cwd: fileURLToPath(root), + settings, + fsMod: fs, + }, + defaultLogging + ); expect(manifest.routes[0].route).to.equal('/foo'); });