fix(router): preserve specificity for redirects
Previously when comparing which of multiple possible routes to choose in an ambiguous case, we looked at the specificity of the target of redirect matches rather than the original match. This meant that if a redirect used a whilecard, but redirected to a target that was a static path, we'd cound the static path's specificity instead of the wildcard. This change stores the specificity of the redirect on the RedirectInstruction. Closes #5933
This commit is contained in:
@ -281,9 +281,11 @@ export class UnresolvedInstruction extends Instruction {
|
||||
|
||||
export class RedirectInstruction extends ResolvedInstruction {
|
||||
constructor(component: ComponentInstruction, child: Instruction,
|
||||
auxInstruction: {[key: string]: Instruction}) {
|
||||
auxInstruction: {[key: string]: Instruction}, private _specificity: string) {
|
||||
super(component, child, auxInstruction);
|
||||
}
|
||||
|
||||
get specificity(): string { return this._specificity; }
|
||||
}
|
||||
|
||||
|
||||
|
@ -205,7 +205,7 @@ export class RouteRegistry {
|
||||
var instruction =
|
||||
this.generate(candidate.redirectTo, ancestorInstructions.concat([null]));
|
||||
return new RedirectInstruction(instruction.component, instruction.child,
|
||||
instruction.auxInstruction);
|
||||
instruction.auxInstruction, candidate.specificity);
|
||||
}
|
||||
}));
|
||||
|
||||
|
Reference in New Issue
Block a user