Skip to content

Commit

Permalink
Put the cluster_uuid in quotes (elastic#83987) (elastic#84328)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
chrisronline and kibanamachine committed Nov 25, 2020
1 parent 40bd49d commit 9440389
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('getSafeForExternalLink', () => {
location
)
).toBe(
`#/overview?_g=(cluster_uuid:NDKg6VXAT6-TaGzEK2Zy7g,filters:!(),refreshInterval:(pause:!t,value:10000),time:(from:'2017-09-07T20:12:04.011Z',to:'2017-09-07T20:18:55.733Z'))`
`#/overview?_g=(cluster_uuid:'NDKg6VXAT6-TaGzEK2Zy7g',filters:!(),refreshInterval:(pause:!t,value:10000),time:(from:'2017-09-07T20:12:04.011Z',to:'2017-09-07T20:18:55.733Z'))`
);
});

Expand All @@ -68,7 +68,7 @@ describe('getSafeForExternalLink', () => {
location
)
).toBe(
`#/overview?_g=(filters:!(),refreshInterval:(pause:!t,value:10000),time:(from:'2017-09-07T20:12:04.011Z',to:'2017-09-07T20:18:55.733Z'),cluster_uuid:NDKg6VXAT6-TaGzEK2Zy7g)`
`#/overview?_g=(filters:!(),refreshInterval:(pause:!t,value:10000),time:(from:'2017-09-07T20:12:04.011Z',to:'2017-09-07T20:18:55.733Z'),cluster_uuid:'NDKg6VXAT6-TaGzEK2Zy7g')`
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ export function getSafeForExternalLink(

let newGlobalState = globalStateExecResult[1];
Object.keys(globalState).forEach((globalStateKey) => {
let value = globalState[globalStateKey];
if (globalStateKey === 'cluster_uuid') {
value = `'${value}'`;
}
const keyRegExp = new RegExp(`${globalStateKey}:([^,]+)`);
const execResult = keyRegExp.exec(newGlobalState);
if (execResult && execResult.length) {
newGlobalState = newGlobalState.replace(
execResult[0],
`${globalStateKey}:${globalState[globalStateKey]}`
);
newGlobalState = newGlobalState.replace(execResult[0], `${globalStateKey}:${value}`);
} else {
newGlobalState += `,${globalStateKey}:${globalState[globalStateKey]}`;
newGlobalState += `,${globalStateKey}:${value}`;
}
});

Expand Down

0 comments on commit 9440389

Please sign in to comment.