1

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)?

Bart van den Burg
  • 2,166
  • 4
  • 25
  • 42
  • Never encountered this problem before, it might be due to using the @ in the url. Maybe its not allowed? So you could try without @ to see if it solves the problem. Some reading material on using @ in urls: https://stackoverflow.com/questions/19509028/can-i-use-an-at-symbol-inside-urls – enf0rcer Dec 04 '18 at 14:09

0 Answers0