mirror of https://github.com/status-im/consul.git
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:
parent
0653bb57ac
commit
38fed7d2b6
|
@ -188,10 +188,14 @@ export default class FSMWithOptionalLocation {
|
||||||
/**
|
/**
|
||||||
* Turns a routeName into a full URL string for anchor hrefs etc.
|
* 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') {
|
if (typeof hash.dc !== 'undefined') {
|
||||||
delete hash.dc;
|
delete hash.dc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof hash.nspace !== 'undefined') {
|
if (typeof hash.nspace !== 'undefined') {
|
||||||
hash.nspace = `~${hash.nspace}`;
|
hash.nspace = `~${hash.nspace}`;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue