fix(@cockpit/explorer): slice contract function result string only if starts/ends with double-quote

Closes #1636.
This commit is contained in:
Michael Bradley, Jr 2019-05-24 17:15:09 -05:00 committed by Pascal Precht
parent d116549c32
commit ac76a40a61

View File

@ -133,6 +133,17 @@ class ContractFunction extends Component {
);
}
formatResult(result) {
result = JSON.stringify(result);
if (result.startsWith('"')) {
result = result.slice(1);
}
if (result.endsWith('"')) {
result = result.slice(0, -1);
}
return result;
}
render() {
if (ContractFunction.isEvent(this.props.method)) {
return <React.Fragment/>;
@ -244,7 +255,7 @@ class ContractFunction extends Component {
Result: &nbsp;
<strong>
<span className="contract-function-result">
{JSON.stringify(contractFunction.result).slice(1, -1)}
{this.formatResult(contractFunction.result)}
</span>
</strong>
</ListGroupItem>