diff options
author | 2023-10-18 13:33:55 +0000 | |
---|---|---|
committer | 2023-10-18 13:33:55 +0000 | |
commit | a44a7a9809aab72b434f883e6fb11b259cc3965c (patch) | |
tree | b1375f3eb03cae0c8e88683dafc489d2de9493fb | |
parent | ad2bb9155997380d0880b0c6c7b12f079a031d48 (diff) | |
download | astro-a44a7a9809aab72b434f883e6fb11b259cc3965c.tar.gz astro-a44a7a9809aab72b434f883e6fb11b259cc3965c.tar.zst astro-a44a7a9809aab72b434f883e6fb11b259cc3965c.zip |
[ci] format
Diffstat (limited to '')
-rw-r--r-- | packages/astro/src/core/app/index.ts | 13 | ||||
-rw-r--r-- | 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 6475718ac..b6bf838a9 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<Response> { + async #renderError( + request: Request, + { status, response: originalResponse, skipMiddleware = false }: RenderErrorOptions + ): Promise<Response> { 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 b882fcc84..66abce3b8 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("<h1>There was an error rendering the page.</h1>") + expect(text).to.include('<h1>There was an error rendering the page.</h1>'); }); it('the integration should receive the path to the middleware', async () => { |