diff --git a/src/js/components/Preview.react.js b/src/js/components/Preview.react.js index eca61aa..db00255 100644 --- a/src/js/components/Preview.react.js +++ b/src/js/components/Preview.react.js @@ -58,31 +58,28 @@ class Preview extends React.Component { this.props.rules, this.props.settings ); - if ( + const hasRequiredField = !!( generatedRules && generatedRules.rules.find(rule => rule.class === 'GlobalRule') - ) { - this.preview.loadURL( - 'http://127.0.0.1:8105/preview.php?url=' + - encodeURIComponent(this.props.editor.url), - { + ); + this.preview.loadURL( + 'http://127.0.0.1:8105/preview.php?url=' + + encodeURIComponent(this.props.editor.url), + hasRequiredField + ? { postData: [ { type: 'rawData', bytes: Buffer.from( - 'rules=' + encodeURIComponent(JSON.stringify(generatedRules)) + 'rules=' + + encodeURIComponent(JSON.stringify(generatedRules)) ), }, ], extraHeaders: 'Content-Type: application/x-www-form-urlencoded', } - ); - } else { - this.preview.loadURL( - 'http://127.0.0.1:8105/preview.php?url=' + - encodeURIComponent(this.props.editor.url) - ); - } + : null + ); } }, 1000);