Skip to content

Commit

Permalink
Ignore postmessage requests with api field set.
Browse files Browse the repository at this point in the history
  • Loading branch information
rxl881 committed Dec 19, 2017
1 parent fa14bc9 commit b5f6d97
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/ScalarMessaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,16 @@ const onMessage = function(event) {
//
// All strings start with the empty string, so for sanity return if the length
// of the event origin is 0.
//
// TODO -- Scalar postMessage API should be namespaced with event.data.api field
// Fix following "if" statement to respond only to specific API messages.
const url = SdkConfig.get().integrations_ui_url;
if (event.origin.length === 0 || !url.startsWith(event.origin) || !event.data.action) {
if (
event.origin.length === 0 ||
!url.startsWith(event.origin) ||
!event.data.action ||
event.data.api // Ignore messages with specific API set
) {
return; // don't log this - debugging APIs like to spam postMessage which floods the log otherwise
}

Expand Down

0 comments on commit b5f6d97

Please sign in to comment.