HostRoutes Class — astro Architecture
Architecture documentation for the HostRoutes class in host-route.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 1c49873f_9e0f_a697_0d8d_933cddc2986d["HostRoutes"] ad6a2143_4751_effa_9c1f_a5f673b5dd66["host-route.ts"] 1c49873f_9e0f_a697_0d8d_933cddc2986d -->|defined in| ad6a2143_4751_effa_9c1f_a5f673b5dd66 b1f43f3f_9019_e0e4_9d66_75b560d13654["add()"] 1c49873f_9e0f_a697_0d8d_933cddc2986d -->|method| b1f43f3f_9019_e0e4_9d66_75b560d13654 db3c0bb0_d54a_5a1e_4475_0bdde7ed1b5a["empty()"] 1c49873f_9e0f_a697_0d8d_933cddc2986d -->|method| db3c0bb0_d54a_5a1e_4475_0bdde7ed1b5a
Relationship Graph
Source Code
packages/underscore-redirects/src/host-route.ts lines 16–51
export class HostRoutes {
public definitions: HostRouteDefinition[] = [];
public minInputLength = 4;
public minTargetLength = 4;
/**
* Adds a new definition by inserting it into the list of definitions
* prioritized by the given weight. This keeps higher priority definitions
* At the top of the list once printed.
*/
add(definition: HostRouteDefinition) {
// Find the longest input, so we can format things nicely
if (definition.input.length > this.minInputLength) {
this.minInputLength = definition.input.length;
}
// Same for the target
if (definition.target && definition.target.length > this.minTargetLength) {
this.minTargetLength = definition.target.length;
}
binaryInsert(this.definitions, definition, (a, b) => {
if (a.weight && b.weight) {
return a.weight > b.weight;
} else {
return false;
}
});
}
/**
* Removes all the saved route definitions
*/
empty(): boolean {
return this.definitions.length === 0;
}
}
Source
Frequently Asked Questions
What is the HostRoutes class?
HostRoutes is a class in the astro codebase, defined in packages/underscore-redirects/src/host-route.ts.
Where is HostRoutes defined?
HostRoutes is defined in packages/underscore-redirects/src/host-route.ts at line 16.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free