Skip to content

Commit e1c8e05

Browse files
alan-agius4clydin
authored andcommitted
refactor(@angular/ssr): remove unused segment property from metadata
The `segment` property within the route-tree metadata is redundant and serves no functional purpose. Therefore, it has been removed. (cherry picked from commit b9151e2)
1 parent ec8f589 commit e1c8e05

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

packages/angular/ssr/src/routes/route-tree.ts

+4-14
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,6 @@ export interface RouteTreeNodeMetadata {
7878
* The `AdditionalMetadata` type parameter allows for extending the node metadata with custom data.
7979
*/
8080
interface RouteTreeNode<AdditionalMetadata extends Record<string, unknown>> {
81-
/**
82-
* The segment value associated with this node.
83-
* A segment is a single part of a route path, typically delimited by slashes (`/`).
84-
* For example, in the route `/users/:id/profile`, the segments are `users`, `:id`, and `profile`.
85-
* Segments can also be wildcards (`*`), which match any segment in that position of the route.
86-
*/
87-
segment: string;
88-
8981
/**
9082
* The index indicating the order in which the route was inserted into the tree.
9183
* This index helps determine the priority of routes during matching, with lower indexes
@@ -116,7 +108,7 @@ export class RouteTree<AdditionalMetadata extends Record<string, unknown> = {}>
116108
* The root node of the route tree.
117109
* All routes are stored and accessed relative to this root node.
118110
*/
119-
private readonly root = this.createEmptyRouteTreeNode('<root>');
111+
private readonly root = this.createEmptyRouteTreeNode();
120112

121113
/**
122114
* A counter that tracks the order of route insertion.
@@ -144,7 +136,7 @@ export class RouteTree<AdditionalMetadata extends Record<string, unknown> = {}>
144136
let childNode = node.children.get(normalizedSegment);
145137

146138
if (!childNode) {
147-
childNode = this.createEmptyRouteTreeNode(normalizedSegment);
139+
childNode = this.createEmptyRouteTreeNode();
148140
node.children.set(normalizedSegment, childNode);
149141
}
150142

@@ -311,15 +303,13 @@ export class RouteTree<AdditionalMetadata extends Record<string, unknown> = {}>
311303
}
312304

313305
/**
314-
* Creates an empty route tree node with the specified segment.
306+
* Creates an empty route tree node.
315307
* This helper function is used during the tree construction.
316308
*
317-
* @param segment - The route segment that this node represents.
318309
* @returns A new, empty route tree node.
319310
*/
320-
private createEmptyRouteTreeNode(segment: string): RouteTreeNode<AdditionalMetadata> {
311+
private createEmptyRouteTreeNode(): RouteTreeNode<AdditionalMetadata> {
321312
return {
322-
segment,
323313
insertionIndex: -1,
324314
children: new Map(),
325315
};

0 commit comments

Comments
 (0)