fix(router): Fix _lastPathIndex in deeply nested empty paths (#22394)
PR Close #22394
This commit is contained in:

committed by
Victor Berchet

parent
1e28495c89
commit
968f153491
@ -417,6 +417,36 @@ export interface ExtraOptions {
|
||||
* - `'eager'`, updates browser URL at the beginning of navigation.
|
||||
*/
|
||||
urlUpdateStrategy?: 'deferred'|'eager';
|
||||
|
||||
/**
|
||||
* Enables a bug fix that corrects relative link resolution in components with empty paths.
|
||||
* Example:
|
||||
*
|
||||
* ```
|
||||
* const routes = [
|
||||
* {
|
||||
* path: '',
|
||||
* component: ContainerComponent,
|
||||
* children: [
|
||||
* { path: 'a', component: AComponent },
|
||||
* { path: 'b', component: BComponent },
|
||||
* ]
|
||||
* }
|
||||
* ];
|
||||
* ```
|
||||
*
|
||||
* From the `ContainerComponent`, this will not work:
|
||||
*
|
||||
* `<a [routerLink]="['./a']">Link to A</a>`
|
||||
*
|
||||
* However, this will work:
|
||||
*
|
||||
* `<a [routerLink]="['../a']">Link to A</a>`
|
||||
*
|
||||
* In other words, you're required to use `../` rather than `./`. The current default in v6
|
||||
* is `legacy`, and this option will be removed in v7 to default to the corrected behavior.
|
||||
*/
|
||||
relativeLinkResolution?: 'legacy'|'corrected';
|
||||
}
|
||||
|
||||
export function setupRouter(
|
||||
@ -465,6 +495,10 @@ export function setupRouter(
|
||||
router.urlUpdateStrategy = opts.urlUpdateStrategy;
|
||||
}
|
||||
|
||||
if (opts.relativeLinkResolution) {
|
||||
router.relativeLinkResolution = opts.relativeLinkResolution;
|
||||
}
|
||||
|
||||
return router;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user