Fix href-to persists hash

Copy passed hash before manipulating it.

Assigning to the same hash object will break href-to
because in certain scenarios href-to-helper will
not create a new object that gets passed to
`fsm-with-optional`-hrefTo method.

This is problematic for optional route-params, and lead
to a situation where links to peered services would
create the wrong url for their href-attribute.
This commit is contained in:
Michael Klein 2022-10-13 11:44:34 +02:00
parent 4c2a5c31dc
commit d9b4f5dab4
1 changed files with 5 additions and 1 deletions

View File

@ -188,10 +188,14 @@ export default class FSMWithOptionalLocation {
/**
* Turns a routeName into a full URL string for anchor hrefs etc.
*/
hrefTo(routeName, params, hash) {
hrefTo(routeName, params, _hash) {
// copy to always work with a new hash even when helper persists hash
const hash = { ..._hash };
if (typeof hash.dc !== 'undefined') {
delete hash.dc;
}
if (typeof hash.nspace !== 'undefined') {
hash.nspace = `~${hash.nspace}`;
}