From a44a7a9809aab72b434f883e6fb11b259cc3965c Mon Sep 17 00:00:00 2001 From: lilnasy Date: Wed, 18 Oct 2023 13:33:55 +0000 Subject: [PATCH] [ci] format --- packages/astro/src/core/app/index.ts | 13 ++++++++++--- packages/astro/test/middleware.test.js | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/astro/src/core/app/index.ts b/packages/astro/src/core/app/index.ts index 6475718aca..b6bf838a93 100644 --- a/packages/astro/src/core/app/index.ts +++ b/packages/astro/src/core/app/index.ts @@ -43,7 +43,7 @@ export interface RenderErrorOptions { status: 404 | 500; /** * Whether to skip onRequest() while rendering the error page. Defaults to false. - */ + */ skipMiddleware?: boolean; } @@ -256,7 +256,10 @@ export class App { * If it is a known error code, try sending the according page (e.g. 404.astro / 500.astro). * This also handles pre-rendered /404 or /500 routes */ - async #renderError(request: Request, { status, response: originalResponse, skipMiddleware = false }: RenderErrorOptions): Promise { + async #renderError( + request: Request, + { status, response: originalResponse, skipMiddleware = false }: RenderErrorOptions + ): Promise { const errorRouteData = matchRoute('/' + status, this.#manifestData); const url = new URL(request.url); if (errorRouteData) { @@ -296,7 +299,11 @@ export class App { } catch { // Middleware may be the cause of the error, so we try rendering 404/500.astro without it. if (skipMiddleware === false && mod.onRequest) { - return this.#renderError(request, { status, response: originalResponse, skipMiddleware: true }); + return this.#renderError(request, { + status, + response: originalResponse, + skipMiddleware: true, + }); } } } diff --git a/packages/astro/test/middleware.test.js b/packages/astro/test/middleware.test.js index b882fcc84c..66abce3b87 100644 --- a/packages/astro/test/middleware.test.js +++ b/packages/astro/test/middleware.test.js @@ -222,12 +222,12 @@ describe('Middleware API in PROD mode, SSR', () => { it('should render 500.astro when the middleware throws an error', async () => { const request = new Request('http://example.com/throw'); const routeData = app.match(request, { matchNotFound: true }); - + const response = await app.render(request, routeData); expect(response).to.deep.include({ status: 500 }); const text = await response.text(); - expect(text).to.include("

There was an error rendering the page.

") + expect(text).to.include('

There was an error rendering the page.

'); }); it('the integration should receive the path to the middleware', async () => {