import React from 'react'; import PropTypes from 'prop-types'; import url from 'url'; import { _t } from '../../../languageHandler'; import SdkConfig from '../../../SdkConfig'; export default class AppPermission extends React.Component { constructor(props) { super(props); const curlBase = this.getCurlBase(); this.state = { curlBase: curlBase}; } // Return string representation of content URL without query parameters getCurlBase() { const wurl = url.parse(this.props.url); let curl; let curlString; const searchParams = new URLSearchParams(wurl.search); if (this.isScalarWurl(wurl) && searchParams && searchParams.get('url')) { curl = url.parse(searchParams.get('url')); if (curl) { curl.search = curl.query = ""; curlString = curl.format(); } } if (!curl && wurl) { wurl.search = wurl.query = ""; curlString = wurl.format(); } return curlString; } isScalarWurl(wurl) { // Exit early if we've been given bad data if (!wurl) { return false; } let scalarUrls = SdkConfig.get().integrations_widgets_urls; if (!scalarUrls || scalarUrls.length == 0) { scalarUrls = [SdkConfig.get().integrations_rest_url]; } const url = wurl.format(); for (const scalarUrl of scalarUrls) { if (url.startsWith(scalarUrl)) { return true; } } return false; } render() { let e2eWarningText; if (this.props.isRoomEncrypted) { e2eWarningText = { _t('NOTE: Apps are not end-to-end encrypted') }; } const cookieWarning = { _t('Warning: This widget might use cookies.') } ; return (