dotJEM / angular-routing

Enhanced state based routing for Angular applications!
https://dotjem.github.io/angular-routing/
MIT License
75 stars 9 forks source link

Impossible to configure similar routes #132

Open thorn0 opened 9 years ago

thorn0 commented 9 years ago

Let's try to configure two routes: 1) {regex(^\w+$):foo}/{regex(^\d+$):bar} 2) {regex(^\w+$):foo}/{regex(^[a-z]+$):bar}

The only difference between them is inside the second regex. If we try to open a URL that matches the first route, we'll see that this route can't be found. If we look into $route.routes in the console, we'll see something like:

▶ /$0:regex/$1:regex: Object
▶ null: Object

Only one entry instead of two.

jeme commented 9 years ago

that would be around here that something needs to change:

https://github.com/dotJEM/angular-routing/blob/master/src/route.ts#L357

The normalization is intentional, so /route/:a and /route/:b won't generate two routes where the second never will be used as they match the same thing.

That said, when it comes to parameters with converters, the arguments ofc. needs to be accounted for. I don't have much time these days as I have so many other things to work on, but feel free to propose a solution.