Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Commit

Permalink
Handle issue with preview #146
Browse files Browse the repository at this point in the history
  • Loading branch information
nataliemt committed Feb 24, 2021
1 parent 2558877 commit 99e0ced
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/js/components/Preview.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,28 @@ class Preview extends React.Component<Props, State> {
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);

Expand Down

0 comments on commit 99e0ced

Please sign in to comment.