Home / Function/ getMatchRegex() — astro Function Reference

getMatchRegex() — astro Function Reference

Architecture documentation for the getMatchRegex() function in redirects.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  4f26bee2_4f80_e528_cf37_94da7aeecde4["getMatchRegex()"]
  2eae0c6b_820a_2609_b99a_dfcd5eb248a7["redirects.ts"]
  4f26bee2_4f80_e528_cf37_94da7aeecde4 -->|defined in| 2eae0c6b_820a_2609_b99a_dfcd5eb248a7
  1af7fd3e_e678_b33e_6570_2ec1ee608783["escapeRegex()"]
  1af7fd3e_e678_b33e_6570_2ec1ee608783 -->|calls| 4f26bee2_4f80_e528_cf37_94da7aeecde4
  style 4f26bee2_4f80_e528_cf37_94da7aeecde4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/integrations/vercel/src/lib/redirects.ts lines 59–86

function getMatchRegex(segments: RoutePart[][]) {
	return segments
		.map((segment, segmentIndex) => {
			return segment.length === 1 && segment[0].spread
				? '(?:\\/(.*?))?'
				: // Omit leading slash if segment is a spread.
					// This is handled using a regex in Astro core.
					// To avoid complex data massaging, we handle in-place here.
					(segmentIndex === 0 ? '' : '/') +
						segment
							.map((part) => {
								if (part)
									return part.spread
										? '(.*?)'
										: part.dynamic
											? '([^/]+?)'
											: part.content
													.normalize()
													.replace(/\?/g, '%3F')
													.replace(/#/g, '%23')
													.replace(/%5B/g, '[')
													.replace(/%5D/g, ']')
													.replace(/[*+?^${}()|[\]\\]/g, '\\$&');
							})
							.join('');
		})
		.join('');
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does getMatchRegex() do?
getMatchRegex() is a function in the astro codebase, defined in packages/integrations/vercel/src/lib/redirects.ts.
Where is getMatchRegex() defined?
getMatchRegex() is defined in packages/integrations/vercel/src/lib/redirects.ts at line 59.
What calls getMatchRegex()?
getMatchRegex() is called by 1 function(s): escapeRegex.

Analyze Your Own Codebase

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

Try Supermodel Free