From a150669a66811c6bff3e15f8442ac80dc969d657 Mon Sep 17 00:00:00 2001 From: brysonbw Date: Tue, 11 Aug 2026 04:50:28 -0500 Subject: [PATCH] feat(router): add containsTree as public API Export containsTree from @angular/router to enable direct UrlTree subset matching. --- goldens/public-api/router/index.api.md | 3 +++ packages/router/src/index.ts | 1 + packages/router/src/url_tree.ts | 9 +++++++++ 3 files changed, 13 insertions(+) diff --git a/goldens/public-api/router/index.api.md b/goldens/public-api/router/index.api.md index 765ae315633..6d5b76838dd 100644 --- a/goldens/public-api/router/index.api.md +++ b/goldens/public-api/router/index.api.md @@ -205,6 +205,9 @@ export interface ComponentInputBindingOptions { unmatchedInputBehavior?: 'alwaysUndefined' | 'undefinedIfStale'; } +// @public +export function containsTree(container: UrlTree, containee: UrlTree, options: IsActiveMatchOptions): boolean; + // @public export function convertToParamMap(params: Params): ParamMap; diff --git a/packages/router/src/index.ts b/packages/router/src/index.ts index 6513a0d7044..abfa4b04e49 100644 --- a/packages/router/src/index.ts +++ b/packages/router/src/index.ts @@ -140,6 +140,7 @@ export { UrlSegmentGroup, UrlSerializer, UrlTree, + containsTree, } from './url_tree'; export { mapToCanActivate, diff --git a/packages/router/src/url_tree.ts b/packages/router/src/url_tree.ts index ee6853cc087..38a9fc31e7c 100644 --- a/packages/router/src/url_tree.ts +++ b/packages/router/src/url_tree.ts @@ -130,6 +130,15 @@ export function isActive( ); } +/** + * Determines if a `UrlTree` is contained within another `UrlTree` based on the provided matching options. + * + * @param container The outer or reference `UrlTree`. + * @param containee The target `UrlTree` to test against the container. + * @param options Matching rules for paths, matrix parameters, query parameters, and fragments. + * + * @publicApi + */ export function containsTree( container: UrlTree, containee: UrlTree,