From a52bb9d6039d52a255b160a2da007b06b6cfe48a Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Thu, 2 Nov 2017 17:27:59 +0000 Subject: [PATCH] Pass URL to check. --- src/components/views/elements/AppTile.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/views/elements/AppTile.js b/src/components/views/elements/AppTile.js index 1a6683fc8b..a440c1703c 100644 --- a/src/components/views/elements/AppTile.js +++ b/src/components/views/elements/AppTile.js @@ -82,15 +82,23 @@ export default React.createClass({ return this._getNewUrlState(this.props); }, - // Returns true if props.url is a scalar URL, typically https://scalar.vector.im/api - isScalarUrl() { + /** + * Returns true if specified url is a scalar URL, typically https://scalar.vector.im/api + * @param {[type]} url URL to check + * @return {Boolean} True if specified URL is a scalar URL + */ + isScalarUrl(url) { + if (!url) { + return false; + } + let scalarUrls = SdkConfig.get().integrations_widgets_urls; if (!scalarUrls || scalarUrls.length == 0) { scalarUrls = [SdkConfig.get().integrations_rest_url]; } for (let i = 0; i < scalarUrls.length; i++) { - if (this.props.url.startsWith(scalarUrls[i])) { + if (url.startsWith(scalarUrls[i])) { return true; } } @@ -122,7 +130,7 @@ export default React.createClass({ // Adds a scalar token to the widget URL, if required setScalarToken() { - if (!this.isScalarUrl()) { + if (!this.isScalarUrl(this.props.url)) { return; } // Fetch the token before loading the iframe as we need to mangle the URL