Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(startsWith matcher): slice all url segments including items before mfe baseHref #301

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libs/angular-webcomponents/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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) => {
Expand All @@ -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)
}

Expand Down
Loading