mirror of
https://github.com/element-hq/element-web
synced 2024-11-28 20:38:55 +03:00
Pass URL to check.
This commit is contained in:
parent
17c0405862
commit
a52bb9d603
1 changed files with 12 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue