From 9dabf19d1be185473ec501cf2c9c3288ccce2529 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Fri, 1 Dec 2017 16:35:55 +0000 Subject: [PATCH] Improve readability. --- src/WidgetMessaging.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/WidgetMessaging.js b/src/WidgetMessaging.js index 8708727c0f..0638d557d1 100644 --- a/src/WidgetMessaging.js +++ b/src/WidgetMessaging.js @@ -232,17 +232,13 @@ function onMessage(event) { * @return {boolean} True if trusted */ function trustedEndpoint(origin) { - if (origin) { - if (messageEndpoints.filter(function(endpoint) { - if (endpoint.endpointUrl == origin) { - return true; - } - }).length > 0) { - return true; - } + if (!origin) { + return false; } - return false; + return messageEndpoints.some((endpoint) => { + return endpoint.endpointUrl === origin; + }); } /**