Home / Function/ requestUrl() — astro Function Reference

requestUrl() — astro Function Reference

Architecture documentation for the requestUrl() function in render-context.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  d422ab4a_ce3f_42d6_8a4b_b096a68675e5["requestUrl()"]
  b7425a46_8c1f_1122_7ae3_a00e52db1d90["RenderContext"]
  d422ab4a_ce3f_42d6_8a4b_b096a68675e5 -->|defined in| b7425a46_8c1f_1122_7ae3_a00e52db1d90
  style d422ab4a_ce3f_42d6_8a4b_b096a68675e5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/core/render-context.ts lines 87–103

	static #createNormalizedUrl(requestUrl: string): URL {
		const url = new URL(requestUrl);
		try {
			// Decode and validate pathname to prevent multi-level encoding bypass attacks
			url.pathname = validateAndDecodePathname(url.pathname);
		} catch {
			// If validation fails, return URL with pathname as-is
			// This will be caught elsewhere in the request handling pipeline
			// For now, just decode without validation to maintain compatibility
			try {
				url.pathname = decodeURI(url.pathname);
			} catch {
				// If even basic decoding fails, return URL as-is
			}
		}
		return url;
	}

Domain

Subdomains

Frequently Asked Questions

What does requestUrl() do?
requestUrl() is a function in the astro codebase, defined in packages/astro/src/core/render-context.ts.
Where is requestUrl() defined?
requestUrl() is defined in packages/astro/src/core/render-context.ts at line 87.

Analyze Your Own Codebase

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

Try Supermodel Free