Home / File/ query.ts — astro Source File

query.ts — astro Source File

Architecture documentation for query.ts, a typescript file in the astro codebase.

Entity Profile

Relationship Graph

Source Code

interface AstroQuery {
	astro?: boolean;
	src?: boolean;
	type?: 'script' | 'template' | 'style' | 'custom';
	index?: number;
	lang?: string;
	raw?: boolean;
	inline?: boolean;
}

interface ParsedRequestResult {
	filename: string;
	query: AstroQuery;
}

// Parses an id to check if it's an Astro request.
// CSS is imported like `import '/src/pages/index.astro?astro&type=style&index=0&lang.css';
// This parses those ids and returns an object representing what it found.
export function parseAstroRequest(id: string): ParsedRequestResult {
	const [filename, rawQuery] = id.split(`?`, 2);
	const query = Object.fromEntries(new URLSearchParams(rawQuery).entries()) as AstroQuery;
	if (query.astro != null) {
		query.astro = true;
	}
	if (query.src != null) {
		query.src = true;
	}
	if (query.index != null) {
		query.index = Number(query.index);
	}
	if (query.raw != null) {
		query.raw = true;
	}
	if (query.inline != null) {
		query.inline = true;
	}
	return {
		filename,
		query,
	};
}

Domain

Subdomains

Frequently Asked Questions

What does query.ts do?
query.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RenderingEngine subdomain.
What functions are defined in query.ts?
query.ts defines 1 function(s): parseAstroRequest.
Where is query.ts in the architecture?
query.ts is located at packages/astro/src/vite-plugin-astro/query.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/vite-plugin-astro).

Analyze Your Own Codebase

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

Try Supermodel Free