<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import url from 'url';
import { _t } from '../../../languageHandler';

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) {
        if(wurl && wurl.hostname && (
            wurl.hostname === 'scalar.vector.im' ||
            wurl.hostname === 'scalar-staging.riot.im' ||
            wurl.hostname === 'demo.riot.im' ||
            wurl.hostname === 'localhost'
        )) {
            return true;
        }<commit_msg>scalar-develop is a scalar URL<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import url from 'url';
import { _t } from '../../../languageHandler';

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) {
        if(wurl && wurl.hostname && (
            wurl.hostname === 'scalar.vector.im' ||
            wurl.hostname === 'scalar-staging.riot.im' ||
            wurl.hostname === 'scalar-develop.riot.im' ||
            wurl.hostname === 'demo.riot.im' ||
            wurl.hostname === 'localhost'
        )) {
            return true;
        }
{'fraction_non_alphanumeric': 0.13409824309788454, 'fraction_numerical': 0.0, 'mean_word_length': 1.8881987577639752, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5442838', 'n_tokens_mistral': 789, 'n_tokens_neox': 781, 'n_words': 172}