-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Directive routerLink dont correctly work with empty fragment option #29683
Copy link
Copy link
Closed
Description
🐞 bug report
Description
When fragment of routerLink are empty the anchor save # in href.
But expected will remove # character for use clean url.
So, for fix this issue I need use two diffrent temaplates of one link: with fragment and without.
I think this is not pretty decision.
And I think the solution located something here: https://github.com/angular/angular/blob/7.2.x/packages/router/src/url_tree.ts#L293
Now:
const fragment =
typeof tree.fragment === `string` ? `#${encodeUriFragment(tree.fragment !)}` : '';But it should be something like this:
const fragment = (typeof tree.fragment === `string` && tree.fragment)
? `#${encodeUriFragment(tree.fragment !)}` : '';🔬 Minimal Reproduction
<!-- correct link with fragment -->
<a routerLink="/abc" fragment="myFragment">link 1 with fragment</a>
<!-- bug with empty fragment -->
<a routerLink="/def" fragment="">link 2 with blank fragment</a>Reactions are currently unavailable
