i have routing that works as follows:
by default, urls look like this:
/
, /basket
, /insights/something
etc.
However, the user is able to select a subapplication, which gets injected into the URL, so that it then looks like this:
/@app/
, /@app/basket
, /@app/insights/something
.
I managed to extract the first part from the URL using a matcher:
export function routingMatcher(segments) {
if (segments.length === 0 || segments[0].path[0] !== '@') {
return {
consumed: []
};
}
return {
consumed: [ segments[0] ],
posParams: {
subApplicationId: new UrlSegment(segments[0].path.slice(1), {})
}
};
}
However, whenever there's a routerLink directive or a router.navigate
, the @app part is not preserved. I'd have to manually add it to each and every call to router.navigate or routerLink with a non-relative path.
How can I automate this process, so that it is always automatically prepended, unless it's explicitly added already (in case we want to switch subApplications)?