From ebf441331699c069f370be9691dbe8cda624ab7b Mon Sep 17 00:00:00 2001 From: markuczy <129275100+markuczy@users.noreply.github.com> Date: Mon, 1 Jul 2024 15:23:18 +0200 Subject: [PATCH] fix(startsWith matcher): slice all url segments including items before mfe baseHref (#301) * fix: fixed baseHref slice function to include workspace href * feat: deploymentPath used to determine whole prefix --- libs/angular-webcomponents/package.json | 1 + .../src/lib/utils/webcomponent-router.utils.ts | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/angular-webcomponents/package.json b/libs/angular-webcomponents/package.json index 1f01d885..0f2a7a33 100644 --- a/libs/angular-webcomponents/package.json +++ b/libs/angular-webcomponents/package.json @@ -6,6 +6,7 @@ "@angular/platform-browser": "^15.2.7 || ^16.0.0 || ^17.0.0", "@angular/elements": "^15.2.7 || ^16.0.0 || ^17.0.0", "@angular/router": "^15.2.7 || ^16.0.0 || ^17.0.0", + "@onecx/accelerator": "^4", "@onecx/portal-integration-angular": "^4", "rxjs": "~7.8.0" }, diff --git a/libs/angular-webcomponents/src/lib/utils/webcomponent-router.utils.ts b/libs/angular-webcomponents/src/lib/utils/webcomponent-router.utils.ts index 6cf9c1d7..39d999be 100644 --- a/libs/angular-webcomponents/src/lib/utils/webcomponent-router.utils.ts +++ b/libs/angular-webcomponents/src/lib/utils/webcomponent-router.utils.ts @@ -1,4 +1,5 @@ import { Route, UrlMatcher, UrlSegment, UrlSegmentGroup } from '@angular/router' +import { getLocation } from '@onecx/accelerator' export function startsWith(prefix: string): UrlMatcher { return (url: UrlSegment[], UrlSegmentGroup: UrlSegmentGroup, route: Route) => { @@ -20,7 +21,11 @@ export function sliceBaseHref(route: Route, url: UrlSegment[]): UrlSegment[] { 'mfeInfo was not provided for route. initializeRouter function is required to be registered as app initializer.' ) } - const baseHrefSegmentAmount = mfeBaseHref.split('/').filter((value) => value).length + + const baseHrefSegmentAmount = getLocation() + .deploymentPath.concat(mfeBaseHref) + .split('/') + .filter((value) => value).length return url.slice(baseHrefSegmentAmount) }