import { UrlMatcher , UrlSegment , UrlSegmentGroup , } from '@angular/router' ; import { daffUriTruncateLeadingSlash } from '@daffodil/core/routing' ; import { DaffRouteWithDataPath } from '../../model/public_api' ; /**
 * A UrlMatcher that does an exact match against a path stored in the special
 * configuration fields that External Router stores on a Route's data.
 *
 * ```ts
 *  export const routes: Routes = [
 *    {
 *      matcher: daffDataPathUrlMatcher,
 *      data: {
 *        daffExternalRouteType: "CATEGORY",
 *      },
 *      loadChildren: () => import('./category/category.module').then((m) => m.ShopCategoryModule),
 *    }
 * ]
 * ```
 *  daffInsertDataPathStrategy *  DaffRouteWithDataPath export const daffDataPathUrlMatcher = ( segments , group , route ) => { const path = daffUriTruncateLeadingSlash ( segments . reduce ( ( acc , segment ) => acc + '/' + segment . path , '' ) ) ; const paths = route ?. data ?. daffPaths ; if ( ! paths ) { return null ; } return path in paths ? { consumed : segments } : null ; } ;