1
votes

I am trying to include a new routing configuration in an existing application which uses aurelia. I want to match some URL path in between, so I thought of using wildcard. The URL looks like below:

http://localhost:4703/*path/somepage

So when I searched in internet I found the below issue, which says aurelia won't be able to match anything in between a URL by using wildcard

https://github.com/aurelia/router/issues/297

I had a look into the source code of aurelia router to have a better understanding and I found below

https://github.com/aurelia/router/blob/master/src/navigation-instruction.js

Line No: 141

  getWildCardName(): string {
    let wildcardIndex = this.config.route.lastIndexOf('*');
    return this.config.route.substr(wildcardIndex + 1);
  }

Is there any other way I can achieve this?

1

1 Answers

0
votes

From the aurelia router documentation:

Wildcard routes are used to match the "rest" of a path (ie: files/*path matches files/new/doc or files/temp). An object with the rest of the URL after the segment is set as the path property and passed as a parameter to activate() as well.

so you can match the "rest" of the route as a single parameter and deal with it yourself

You can although define a method to deal with unknown routes and check if they end with what you want and handle appropriately