From a8f0372ea71479ef80c58e74201dea6a5a2b2ae4 Mon Sep 17 00:00:00 2001 From: Elias <81151432+Elias-Chairi@users.noreply.github.com> Date: Thu, 16 May 2024 10:26:27 +0200 Subject: [PATCH 1/8] Update generator.ts to allow %23 (#) in dynamic urls (#10965) * Update generator.ts to allow %23 (#) in dynamic urls * added changeset * fix: Update generator.ts to santize url params as well * fix: sanitizeParams function * removed old fix * fix: added test for decoded # and ? * fix: formatting of file * sperated sanitizing of generated paths and ssr dynamic paths * refactor: using map instead * Update .changeset/mean-geckos-sell.md Co-authored-by: Emanuele Stoppa * doc: added JSDoc for sanitizeParams function --------- Co-authored-by: Emanuele Stoppa --- .changeset/mean-geckos-sell.md | 5 ++++ .../src/core/routing/manifest/generator.ts | 24 +++++++++++++++++-- packages/astro/test/ssr-params.test.js | 4 ++-- 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 .changeset/mean-geckos-sell.md diff --git a/.changeset/mean-geckos-sell.md b/.changeset/mean-geckos-sell.md new file mode 100644 index 000000000000..5a72faa07f99 --- /dev/null +++ b/.changeset/mean-geckos-sell.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Update generator.ts to allow %23 (#) in dynamic urls diff --git a/packages/astro/src/core/routing/manifest/generator.ts b/packages/astro/src/core/routing/manifest/generator.ts index 9395a3de2f05..c61ce6dca4f6 100644 --- a/packages/astro/src/core/routing/manifest/generator.ts +++ b/packages/astro/src/core/routing/manifest/generator.ts @@ -2,6 +2,25 @@ import type { AstroConfig, RoutePart } from '../../../@types/astro.js'; import { compile } from 'path-to-regexp'; +/** + * Sanitizes the parameters object by normalizing string values and replacing certain characters with their URL-encoded equivalents. + * @param {Record} params - The parameters object to be sanitized. + * @returns {Record} The sanitized parameters object. + */ +function sanitizeParams(params: Record): Record { + return Object.fromEntries( + Object.entries(params).map(([key, value]) => { + if (typeof value === 'string') { + return [key, value + .normalize() + .replace(/#/g, '%23') + .replace(/\?/g, '%3F')] + } + return [key, value]; + }) + ) +} + export function getRouteGenerator( segments: RoutePart[][], addTrailingSlash: AstroConfig['trailingSlash'] @@ -37,8 +56,9 @@ export function getRouteGenerator( trailing = '/'; } const toPath = compile(template + trailing); - return (params: object): string => { - const path = toPath(params); + return (params: Record): string => { + const sanitizedParams = sanitizeParams(params); + const path = toPath(sanitizedParams); // When generating an index from a rest parameter route, `path-to-regexp` will return an // empty string instead "/". This causes an inconsistency with static indexes that may result diff --git a/packages/astro/test/ssr-params.test.js b/packages/astro/test/ssr-params.test.js index c5d376fbfce0..13c071e7d0f4 100644 --- a/packages/astro/test/ssr-params.test.js +++ b/packages/astro/test/ssr-params.test.js @@ -42,11 +42,11 @@ describe('Astro.params in SSR', () => { it('No double URL decoding', async () => { const app = await fixture.loadTestAdapterApp(); - const request = new Request('http://example.com/users/houston/%25'); + const request = new Request('http://example.com/users/houston/%25%23%3F'); const response = await app.render(request); assert.equal(response.status, 200); const html = await response.text(); const $ = cheerio.load(html); - assert.equal($('.category').text(), '%'); + assert.equal($('.category').text(), '%#?'); }); }); From 303968bd72cf118c6a0914c15057c5b1de5b0af6 Mon Sep 17 00:00:00 2001 From: Elias Date: Thu, 16 May 2024 08:27:20 +0000 Subject: [PATCH 2/8] [ci] format --- packages/astro/src/core/routing/manifest/generator.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/astro/src/core/routing/manifest/generator.ts b/packages/astro/src/core/routing/manifest/generator.ts index c61ce6dca4f6..734aee726dc9 100644 --- a/packages/astro/src/core/routing/manifest/generator.ts +++ b/packages/astro/src/core/routing/manifest/generator.ts @@ -7,18 +7,17 @@ import { compile } from 'path-to-regexp'; * @param {Record} params - The parameters object to be sanitized. * @returns {Record} The sanitized parameters object. */ -function sanitizeParams(params: Record): Record { +function sanitizeParams( + params: Record +): Record { return Object.fromEntries( Object.entries(params).map(([key, value]) => { if (typeof value === 'string') { - return [key, value - .normalize() - .replace(/#/g, '%23') - .replace(/\?/g, '%3F')] + return [key, value.normalize().replace(/#/g, '%23').replace(/\?/g, '%3F')]; } return [key, value]; }) - ) + ); } export function getRouteGenerator( From 3a0c02ae0357c267881b30454b5320075378894b Mon Sep 17 00:00:00 2001 From: n4n5 <56606507+Its-Just-Nans@users.noreply.github.com> Date: Thu, 16 May 2024 12:52:35 +0200 Subject: [PATCH 3/8] add error message for svg without dimensions (#10924) * add svg * throw clean error * add error handling * revert * throw clean error * add changeset * make it a patch * Update remoteProbe.ts --------- Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com> --- .changeset/cold-dolls-do.md | 5 ++++ packages/astro/src/assets/utils/metadata.ts | 30 ++++++++++++--------- 2 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 .changeset/cold-dolls-do.md diff --git a/.changeset/cold-dolls-do.md b/.changeset/cold-dolls-do.md new file mode 100644 index 000000000000..4169415285b0 --- /dev/null +++ b/.changeset/cold-dolls-do.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Handle image-size errors by displaying a clearer message diff --git a/packages/astro/src/assets/utils/metadata.ts b/packages/astro/src/assets/utils/metadata.ts index 953349eb523e..8076d702fa19 100644 --- a/packages/astro/src/assets/utils/metadata.ts +++ b/packages/astro/src/assets/utils/metadata.ts @@ -6,22 +6,28 @@ export async function imageMetadata( data: Uint8Array, src?: string ): Promise> { - const result = probe(data); + try { + const result = probe(data); + if (!result.height || !result.width || !result.type) { + throw new AstroError({ + ...AstroErrorData.NoImageMetadata, + message: AstroErrorData.NoImageMetadata.message(src), + }); + } - if (!result.height || !result.width || !result.type) { + const { width, height, type, orientation } = result; + const isPortrait = (orientation || 0) >= 5; + + return { + width: isPortrait ? height : width, + height: isPortrait ? width : height, + format: type as ImageInputFormat, + orientation, + }; + } catch (e) { throw new AstroError({ ...AstroErrorData.NoImageMetadata, message: AstroErrorData.NoImageMetadata.message(src), }); } - - const { width, height, type, orientation } = result; - const isPortrait = (orientation || 0) >= 5; - - return { - width: isPortrait ? height : width, - height: isPortrait ? width : height, - format: type as ImageInputFormat, - orientation, - }; } From 16f12e426e5869721313bb771e2ec5b821c5452e Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Thu, 16 May 2024 14:43:30 +0100 Subject: [PATCH 4/8] fix(i18n): allow to create 404.html and 500.html (#11062) * fix(i18n): allow to create 404.html and 500.html * Update packages/astro/src/i18n/index.ts Co-authored-by: Florian Lefebvre * Update .changeset/lazy-rockets-raise.md * chore: use better matching * fix linting --------- Co-authored-by: Florian Lefebvre --- .changeset/lazy-rockets-raise.md | 5 +++++ packages/astro/src/i18n/index.ts | 10 +++++++++- packages/astro/src/i18n/middleware.ts | 6 ++++++ .../i18n-routing-prefix-always/src/pages/500.astro | 4 ++++ ...i18n-routing-manual-with-default-middleware.test.js | 5 +++-- packages/astro/test/i18n-routing.test.js | 10 ++++++++++ 6 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 .changeset/lazy-rockets-raise.md create mode 100644 packages/astro/test/fixtures/i18n-routing-prefix-always/src/pages/500.astro diff --git a/.changeset/lazy-rockets-raise.md b/.changeset/lazy-rockets-raise.md new file mode 100644 index 000000000000..44882eee67b1 --- /dev/null +++ b/.changeset/lazy-rockets-raise.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Fixes a bug where `astro build` didn't create custom `404.html` and `500.html` when a certain combination of i18n options was applied diff --git a/packages/astro/src/i18n/index.ts b/packages/astro/src/i18n/index.ts index b8114019bdcf..519d5eda2271 100644 --- a/packages/astro/src/i18n/index.ts +++ b/packages/astro/src/i18n/index.ts @@ -19,6 +19,14 @@ export function requestHasLocale(locales: Locales) { }; } +export function requestIs404Or500(request: Request, base = '') { + const url = new URL(request.url); + + return ( + url.pathname.startsWith(`${base}/404`) || + url.pathname.startsWith(`${base}/500`) + ); +} // Checks if the pathname has any locale export function pathHasLocale(path: string, locales: Locales): boolean { const segments = path.split('/'); @@ -317,7 +325,7 @@ export function notFound({ base, locales }: MiddlewarePayload) { if (!(isRoot || pathHasLocale(url.pathname, locales))) { if (response) { response.headers.set(REROUTE_DIRECTIVE_HEADER, 'no'); - return new Response(null, { + return new Response(response.body, { status: 404, headers: response.headers, }); diff --git a/packages/astro/src/i18n/middleware.ts b/packages/astro/src/i18n/middleware.ts index df5d63761c74..9f9c7348e081 100644 --- a/packages/astro/src/i18n/middleware.ts +++ b/packages/astro/src/i18n/middleware.ts @@ -8,6 +8,7 @@ import { redirectToDefaultLocale, redirectToFallback, requestHasLocale, + requestIs404Or500, } from './index.js'; export function createI18nMiddleware( @@ -69,6 +70,11 @@ export function createI18nMiddleware( return response; } + // 404 and 500 are **known** routes (users can have their custom pages), so we need to let them be + if (requestIs404Or500(context.request, base)) { + return response; + } + const { currentLocale } = context; switch (i18n.strategy) { diff --git a/packages/astro/test/fixtures/i18n-routing-prefix-always/src/pages/500.astro b/packages/astro/test/fixtures/i18n-routing-prefix-always/src/pages/500.astro new file mode 100644 index 000000000000..8bd0a9e216c5 --- /dev/null +++ b/packages/astro/test/fixtures/i18n-routing-prefix-always/src/pages/500.astro @@ -0,0 +1,4 @@ + + Error + Unexpected error. + diff --git a/packages/astro/test/i18n-routing-manual-with-default-middleware.test.js b/packages/astro/test/i18n-routing-manual-with-default-middleware.test.js index bf0f6e8b97a9..1e609f7487b1 100644 --- a/packages/astro/test/i18n-routing-manual-with-default-middleware.test.js +++ b/packages/astro/test/i18n-routing-manual-with-default-middleware.test.js @@ -26,7 +26,7 @@ describe('Dev server manual routing', () => { const response = await fixture.fetch('/blog'); const text = await response.text(); assert.equal(response.status, 404); - assert.equal(text.includes('Blog should not render'), false); + assert.match(text, /Blog should not render/); }); it('should return a 200 because the custom middleware allows it', async () => { @@ -83,7 +83,8 @@ describe('SSR manual routing', () => { let request = new Request('http://example.com/blog'); let response = await app.render(request); assert.equal(response.status, 404); - assert.equal((await response.text()).includes('Blog should not render'), false); + const text = await response.text(); + assert.match(text, /Blog should not render/); }); it('should return a 200 because the custom middleware allows it', async () => { diff --git a/packages/astro/test/i18n-routing.test.js b/packages/astro/test/i18n-routing.test.js index 9723b69dfadb..09581c899732 100644 --- a/packages/astro/test/i18n-routing.test.js +++ b/packages/astro/test/i18n-routing.test.js @@ -580,6 +580,16 @@ describe('[SSG] i18n routing', () => { assert.equal($('body').text().includes('Lo siento'), true); }); + it('should create a custom 404.html and 505.html', async () => { + let html = await fixture.readFile('/404.html'); + let $ = cheerio.load(html); + assert.equal($('body').text().includes("Can't find the page you're looking for."), true); + + html = await fixture.readFile('/500.html'); + $ = cheerio.load(html); + assert.equal($('body').text().includes('Unexpected error.'), true); + }); + it("should NOT render the default locale if there isn't a fallback and the route is missing", async () => { try { await fixture.readFile('/it/start/index.html'); From 87f36d4074c895fb56dfc609f575d40c4c902b32 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Thu, 16 May 2024 13:44:20 +0000 Subject: [PATCH 5/8] [ci] format --- packages/astro/src/i18n/index.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/astro/src/i18n/index.ts b/packages/astro/src/i18n/index.ts index 519d5eda2271..3a12f699231f 100644 --- a/packages/astro/src/i18n/index.ts +++ b/packages/astro/src/i18n/index.ts @@ -22,10 +22,7 @@ export function requestHasLocale(locales: Locales) { export function requestIs404Or500(request: Request, base = '') { const url = new URL(request.url); - return ( - url.pathname.startsWith(`${base}/404`) || - url.pathname.startsWith(`${base}/500`) - ); + return url.pathname.startsWith(`${base}/404`) || url.pathname.startsWith(`${base}/500`); } // Checks if the pathname has any locale export function pathHasLocale(path: string, locales: Locales): boolean { From 1f988ed10f4737b5333c9978115ee531786eb539 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Thu, 16 May 2024 14:52:39 +0100 Subject: [PATCH 6/8] fix(rewrite): match index with params (#11065) * fix(rewrite): match index with params * remove import --- .changeset/brave-cycles-suffer.md | 5 +++++ packages/astro/src/core/app/pipeline.ts | 14 ++++++++++---- packages/astro/src/core/base-pipeline.ts | 5 ++++- packages/astro/src/core/build/pipeline.ts | 14 ++++++++++---- packages/astro/src/core/render-context.ts | 7 +++---- .../astro/src/vite-plugin-astro-server/pipeline.ts | 14 ++++++++++---- .../astro/test/fixtures/reroute/src/middleware.js | 4 ++++ .../fixtures/reroute/src/pages/auth/params.astro | 10 ++++++++++ packages/astro/test/rewrite.test.js | 7 +++++++ 9 files changed, 63 insertions(+), 17 deletions(-) create mode 100644 .changeset/brave-cycles-suffer.md create mode 100644 packages/astro/test/fixtures/reroute/src/pages/auth/params.astro diff --git a/.changeset/brave-cycles-suffer.md b/.changeset/brave-cycles-suffer.md new file mode 100644 index 000000000000..1a8de425661d --- /dev/null +++ b/.changeset/brave-cycles-suffer.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Fixes a bug in the Astro rewrite logic, where rewriting the index with parameters - `next("/?foo=bar")` - didn't work as expected. diff --git a/packages/astro/src/core/app/pipeline.ts b/packages/astro/src/core/app/pipeline.ts index f62dc84ed983..0f59a8b047d2 100644 --- a/packages/astro/src/core/app/pipeline.ts +++ b/packages/astro/src/core/app/pipeline.ts @@ -71,7 +71,10 @@ export class AppPipeline extends Pipeline { return module.page(); } - async tryRewrite(payload: RewritePayload): Promise<[RouteData, ComponentInstance]> { + async tryRewrite( + payload: RewritePayload, + request: Request + ): Promise<[RouteData, ComponentInstance]> { let foundRoute; for (const route of this.#manifestData!.routes) { @@ -86,9 +89,12 @@ export class AppPipeline extends Pipeline { foundRoute = route; break; } - } else if (route.pattern.test(decodeURI(payload))) { - foundRoute = route; - break; + } else { + const newUrl = new URL(payload, new URL(request.url).origin); + if (route.pattern.test(decodeURI(newUrl.pathname))) { + foundRoute = route; + break; + } } } diff --git a/packages/astro/src/core/base-pipeline.ts b/packages/astro/src/core/base-pipeline.ts index 11cff7c809f5..b4ba9e960407 100644 --- a/packages/astro/src/core/base-pipeline.ts +++ b/packages/astro/src/core/base-pipeline.ts @@ -71,7 +71,10 @@ export abstract class Pipeline { * * @param {RewritePayload} rewritePayload */ - abstract tryRewrite(rewritePayload: RewritePayload): Promise<[RouteData, ComponentInstance]>; + abstract tryRewrite( + rewritePayload: RewritePayload, + request: Request + ): Promise<[RouteData, ComponentInstance]>; /** * Tells the pipeline how to retrieve a component give a `RouteData` diff --git a/packages/astro/src/core/build/pipeline.ts b/packages/astro/src/core/build/pipeline.ts index 7661b6fc4d66..664d30c9ad7a 100644 --- a/packages/astro/src/core/build/pipeline.ts +++ b/packages/astro/src/core/build/pipeline.ts @@ -276,7 +276,10 @@ export class BuildPipeline extends Pipeline { } } - async tryRewrite(payload: RewritePayload): Promise<[RouteData, ComponentInstance]> { + async tryRewrite( + payload: RewritePayload, + request: Request + ): Promise<[RouteData, ComponentInstance]> { let foundRoute: RouteData | undefined; // options.manifest is the actual type that contains the information for (const route of this.options.manifest.routes) { @@ -291,9 +294,12 @@ export class BuildPipeline extends Pipeline { foundRoute = route; break; } - } else if (route.pattern.test(decodeURI(payload))) { - foundRoute = route; - break; + } else { + const newUrl = new URL(payload, new URL(request.url).origin); + if (route.pattern.test(decodeURI(newUrl.pathname))) { + foundRoute = route; + break; + } } } if (foundRoute) { diff --git a/packages/astro/src/core/render-context.ts b/packages/astro/src/core/render-context.ts index 5f35c5f11309..4a5cad1da54c 100644 --- a/packages/astro/src/core/render-context.ts +++ b/packages/astro/src/core/render-context.ts @@ -4,7 +4,6 @@ import type { AstroGlobalPartial, ComponentInstance, MiddlewareHandler, - MiddlewareNext, RewritePayload, RouteData, SSRResult, @@ -118,7 +117,7 @@ export class RenderContext { if (payload) { if (this.pipeline.manifest.rewritingEnabled) { try { - const [routeData, component] = await pipeline.tryRewrite(payload); + const [routeData, component] = await pipeline.tryRewrite(payload, this.request); this.routeData = routeData; componentInstance = component; } catch (e) { @@ -212,7 +211,7 @@ export class RenderContext { const rewrite = async (reroutePayload: RewritePayload) => { pipeline.logger.debug('router', 'Called rewriting to:', reroutePayload); try { - const [routeData, component] = await pipeline.tryRewrite(reroutePayload); + const [routeData, component] = await pipeline.tryRewrite(reroutePayload, this.request); this.routeData = routeData; if (reroutePayload instanceof Request) { this.request = reroutePayload; @@ -398,7 +397,7 @@ export class RenderContext { const rewrite = async (reroutePayload: RewritePayload) => { try { pipeline.logger.debug('router', 'Calling rewrite: ', reroutePayload); - const [routeData, component] = await pipeline.tryRewrite(reroutePayload); + const [routeData, component] = await pipeline.tryRewrite(reroutePayload, this.request); this.routeData = routeData; if (reroutePayload instanceof Request) { this.request = reroutePayload; diff --git a/packages/astro/src/vite-plugin-astro-server/pipeline.ts b/packages/astro/src/vite-plugin-astro-server/pipeline.ts index 797c5d29abdd..260f7fa1fa86 100644 --- a/packages/astro/src/vite-plugin-astro-server/pipeline.ts +++ b/packages/astro/src/vite-plugin-astro-server/pipeline.ts @@ -191,7 +191,10 @@ export class DevPipeline extends Pipeline { } } - async tryRewrite(payload: RewritePayload): Promise<[RouteData, ComponentInstance]> { + async tryRewrite( + payload: RewritePayload, + request: Request + ): Promise<[RouteData, ComponentInstance]> { let foundRoute; if (!this.manifestData) { throw new Error('Missing manifest data. This is an internal error, please file an issue.'); @@ -209,9 +212,12 @@ export class DevPipeline extends Pipeline { foundRoute = route; break; } - } else if (route.pattern.test(decodeURI(payload))) { - foundRoute = route; - break; + } else { + const newUrl = new URL(payload, new URL(request.url).origin); + if (route.pattern.test(decodeURI(newUrl.pathname))) { + foundRoute = route; + break; + } } } diff --git a/packages/astro/test/fixtures/reroute/src/middleware.js b/packages/astro/test/fixtures/reroute/src/middleware.js index 4d7c2a7956c8..09f3ef73c4ad 100644 --- a/packages/astro/test/fixtures/reroute/src/middleware.js +++ b/packages/astro/test/fixtures/reroute/src/middleware.js @@ -18,6 +18,10 @@ export const second = async (context, next) => { if (context.url.pathname.includes('/auth/base')) { return await next('/'); } + + if (context.url.pathname.includes('/auth/params')) { + return next('/?foo=bar'); + } } return next(); }; diff --git a/packages/astro/test/fixtures/reroute/src/pages/auth/params.astro b/packages/astro/test/fixtures/reroute/src/pages/auth/params.astro new file mode 100644 index 000000000000..3f4dfad8754b --- /dev/null +++ b/packages/astro/test/fixtures/reroute/src/pages/auth/params.astro @@ -0,0 +1,10 @@ +--- +--- + + + Index with params + + +

Index with params

+ + diff --git a/packages/astro/test/rewrite.test.js b/packages/astro/test/rewrite.test.js index 1c76ce10af74..ef6a90e5dcc0 100644 --- a/packages/astro/test/rewrite.test.js +++ b/packages/astro/test/rewrite.test.js @@ -220,4 +220,11 @@ describe('Middleware', () => { assert.equal($('h1').text(), 'Index'); assert.equal($('p').text(), ''); }); + + it('should render the index when rewriting with params', async () => { + const html = await fixture.fetch('/auth/params').then((res) => res.text()); + const $ = cheerioLoad(html); + + assert.match($('h1').text(), /Index/); + }); }); From 240a70a29f8e11d161da021845c208f982d64e5c Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Thu, 16 May 2024 16:13:32 +0100 Subject: [PATCH 7/8] fix: improve logging for on-demand pages (#11069) --- .changeset/silly-parents-repair.md | 5 +++++ packages/astro/src/core/app/index.ts | 8 ++++++++ 2 files changed, 13 insertions(+) create mode 100644 .changeset/silly-parents-repair.md diff --git a/.changeset/silly-parents-repair.md b/.changeset/silly-parents-repair.md new file mode 100644 index 000000000000..9157e6cc6ec6 --- /dev/null +++ b/.changeset/silly-parents-repair.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Improves debug logging for on-demand pages diff --git a/packages/astro/src/core/app/index.ts b/packages/astro/src/core/app/index.ts index 1ba5d9479833..58dbae9f5986 100644 --- a/packages/astro/src/core/app/index.ts +++ b/packages/astro/src/core/app/index.ts @@ -280,6 +280,10 @@ export class App { this.#logRenderOptionsDeprecationWarning(); } } + if (routeData) { + this.#logger.debug("router", "The adapter " + this.#manifest.adapterName + " provided a custom RouteData for ", request.url); + this.#logger.debug("router", "RouteData:\n" + routeData); + } if (locals) { if (typeof locals !== 'object') { this.#logger.error(null, new AstroError(AstroErrorData.LocalsNotAnObject).stack!); @@ -296,8 +300,12 @@ export class App { } if (!routeData) { routeData = this.match(request); + this.#logger.debug("router", "Astro matched the following route for "+ request.url); + this.#logger.debug("router", "RouteData:\n" + routeData); } if (!routeData) { + this.#logger.debug("router", "Astro hasn't found routes that match " + request.url); + this.#logger.debug("router", "Here's the available routes:\n", this.#manifestData); return this.#renderError(request, { locals, status: 404 }); } const pathname = this.#getPathnameFromRequest(request); From 3830e5d416d00a8abefbc622df5d79e919f502b8 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Thu, 16 May 2024 15:14:23 +0000 Subject: [PATCH 8/8] [ci] format --- packages/astro/src/core/app/index.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/astro/src/core/app/index.ts b/packages/astro/src/core/app/index.ts index 58dbae9f5986..5b941357839c 100644 --- a/packages/astro/src/core/app/index.ts +++ b/packages/astro/src/core/app/index.ts @@ -281,8 +281,12 @@ export class App { } } if (routeData) { - this.#logger.debug("router", "The adapter " + this.#manifest.adapterName + " provided a custom RouteData for ", request.url); - this.#logger.debug("router", "RouteData:\n" + routeData); + this.#logger.debug( + 'router', + 'The adapter ' + this.#manifest.adapterName + ' provided a custom RouteData for ', + request.url + ); + this.#logger.debug('router', 'RouteData:\n' + routeData); } if (locals) { if (typeof locals !== 'object') { @@ -300,12 +304,12 @@ export class App { } if (!routeData) { routeData = this.match(request); - this.#logger.debug("router", "Astro matched the following route for "+ request.url); - this.#logger.debug("router", "RouteData:\n" + routeData); + this.#logger.debug('router', 'Astro matched the following route for ' + request.url); + this.#logger.debug('router', 'RouteData:\n' + routeData); } if (!routeData) { - this.#logger.debug("router", "Astro hasn't found routes that match " + request.url); - this.#logger.debug("router", "Here's the available routes:\n", this.#manifestData); + this.#logger.debug('router', "Astro hasn't found routes that match " + request.url); + this.#logger.debug('router', "Here's the available routes:\n", this.#manifestData); return this.#renderError(request, { locals, status: 404 }); } const pathname = this.#getPathnameFromRequest(request);