Skip to content

Commit

Permalink
refactor(@angular/ssr): update getPathSegments to use `stripTrailin…
Browse files Browse the repository at this point in the history
…gSlash` instead of `filter(Boolean)`

This change modifies the `getPathSegments` function to use `stripTrailingSlash`, providing a more consistent and reliable way to handle trailing slashes in paths. This update also resolves issues causing CI failures.

(cherry picked from commit b0c2d19)
  • Loading branch information
alan-agius4 committed Jan 22, 2025
1 parent 9bacf39 commit c5d9038
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/angular/ssr/src/routes/route-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { addLeadingSlash } from '../utils/url';
import { addLeadingSlash, stripTrailingSlash } from '../utils/url';
import { RenderMode } from './route-config';

/**
Expand Down Expand Up @@ -230,7 +230,7 @@ export class RouteTree<AdditionalMetadata extends Record<string, unknown> = {}>
* @returns An array of path segments.
*/
private getPathSegments(route: string): string[] {
return route.split('/').filter(Boolean);
return stripTrailingSlash(route).split('/');
}

/**
Expand Down

0 comments on commit c5d9038

Please sign in to comment.