Home / Function/ tryRewrite() — astro Function Reference

tryRewrite() — astro Function Reference

Architecture documentation for the tryRewrite() function in pipeline.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  735ba179_276d_3c4c_7c5b_ae306468a54e["tryRewrite()"]
  7feea19b_1eb1_3680_d050_0ea7bb95b6d3["ContainerPipeline"]
  735ba179_276d_3c4c_7c5b_ae306468a54e -->|defined in| 7feea19b_1eb1_3680_d050_0ea7bb95b6d3
  2aa59556_8548_b5bf_a6a6_c3b895612816["getComponentByRoute()"]
  735ba179_276d_3c4c_7c5b_ae306468a54e -->|calls| 2aa59556_8548_b5bf_a6a6_c3b895612816
  style 735ba179_276d_3c4c_7c5b_ae306468a54e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/container/pipeline.ts lines 59–72

	async tryRewrite(payload: RewritePayload, request: Request): Promise<TryRewriteResult> {
		const { newUrl, pathname, routeData } = findRouteToRewrite({
			payload,
			request,
			routes: this.manifest?.routes.map((r) => r.routeData),
			trailingSlash: this.manifest.trailingSlash,
			buildFormat: this.manifest.buildFormat,
			base: this.manifest.base,
			outDir: this.manifest.outDir,
		});

		const componentInstance = await this.getComponentByRoute(routeData);
		return { componentInstance, routeData, newUrl, pathname };
	}

Domain

Subdomains

Frequently Asked Questions

What does tryRewrite() do?
tryRewrite() is a function in the astro codebase, defined in packages/astro/src/container/pipeline.ts.
Where is tryRewrite() defined?
tryRewrite() is defined in packages/astro/src/container/pipeline.ts at line 59.
What does tryRewrite() call?
tryRewrite() calls 1 function(s): getComponentByRoute.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free