import { Injectable , Inject , } from '@angular/core' ; import { Observable , of , } from 'rxjs' ; import { daffUriTruncateLeadingSlash , daffUriTruncateQueryFragment , } from '@daffodil/core/routing' ; import { DaffExternallyResolvableUrl } from '@daffodil/external-router' ; import { DaffExternalRouterDriverInterface , DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION , } from '@daffodil/external-router/driver' ; import { DaffExternalRouterDriverInMemoryConfig , DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG , } from './config' ; inheritdoc see DaffExternalRouterInMemoryDriver @ Injectable ( { providedIn : 'root' , } ) export class DaffExternalRouterInMemoryDriver implements DaffExternalRouterDriverInterface { constructor ( @ Inject ( DAFF_EXTERNAL_ROUTER_DRIVER_IN_MEMORY_CONFIG ) private configuration ) { } resolve ( url ) { const truncatedUrl = daffUriTruncateQueryFragment ( url ) ; const resolvedUrl = this . configuration . resolver ( truncatedUrl ) ; return of ( resolvedUrl ?. url ? { ... resolvedUrl , url : daffUriTruncateLeadingSlash ( resolvedUrl . url ) , } : DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION ) ; } }