Home / Function/ isPublicRoute() — astro Function Reference

isPublicRoute() — astro Function Reference

Architecture documentation for the isPublicRoute() function in util.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  6dddd48e_7b79_3a2c_5963_3ff253a1002d["isPublicRoute()"]
  a3824e79_205c_305b_a44f_edee1ef5faa4["util.ts"]
  6dddd48e_7b79_3a2c_5963_3ff253a1002d -->|defined in| a3824e79_205c_305b_a44f_edee1ef5faa4
  dde926f7_9c30_abb1_62a9_3678f29d2c92["isPage()"]
  dde926f7_9c30_abb1_62a9_3678f29d2c92 -->|calls| 6dddd48e_7b79_3a2c_5963_3ff253a1002d
  fa8579ea_f215_3452_2150_67519e6ea9cb["isEndpoint()"]
  fa8579ea_f215_3452_2150_67519e6ea9cb -->|calls| 6dddd48e_7b79_3a2c_5963_3ff253a1002d
  9ca1d938_50b1_d5ae_db7f_b833b62eaf41["resolvePages()"]
  6dddd48e_7b79_3a2c_5963_3ff253a1002d -->|calls| 9ca1d938_50b1_d5ae_db7f_b833b62eaf41
  style 6dddd48e_7b79_3a2c_5963_3ff253a1002d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/core/util.ts lines 145–163

function isPublicRoute(file: URL, config: AstroConfig): boolean {
	const rootDir = config.root.toString();
	const pagesDir = resolvePages(config).toString();
	const fileDir = file.toString();

	// Normalize the file directory path by removing the pagesDir prefix if it exists,
	// otherwise remove the rootDir prefix.
	const normalizedDir = fileDir.startsWith(pagesDir)
		? fileDir.slice(pagesDir.length)
		: fileDir.slice(rootDir.length);

	const parts = normalizedDir.replace(pagesDir.toString(), '').split('/').slice(1);

	for (const part of parts) {
		if (part.startsWith('_')) return false;
	}

	return true;
}

Domain

Subdomains

Frequently Asked Questions

What does isPublicRoute() do?
isPublicRoute() is a function in the astro codebase, defined in packages/astro/src/core/util.ts.
Where is isPublicRoute() defined?
isPublicRoute() is defined in packages/astro/src/core/util.ts at line 145.
What does isPublicRoute() call?
isPublicRoute() calls 1 function(s): resolvePages.
What calls isPublicRoute()?
isPublicRoute() is called by 2 function(s): isEndpoint, isPage.

Analyze Your Own Codebase

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

Try Supermodel Free