<commit_before>import Service from '@ember/service';

export default class UtilsService extends Service {
    downloadFile(url) {
        let iframe = document.getElementById('iframeDownload');

        if (!iframe) {
            iframe = document.createElement('iframe');
            iframe.id = 'iframeDownload';
            iframe.style.display = 'none';
            document.body.append(iframe);
        }

        iframe.setAttribute('src', url);
    }

    /**
     * Remove tracking parameters from a URL
     * @param {string} url 
     * @param {boolean} [display] Set to true to remove protocol and hash from the URL
     * @returns 
     */
    cleanTrackedUrl(url, display = false) {
        // Remove our own querystring parameters and protocol
        const removeParams = ['rel', 'attribution_id', 'attribution_type'];
        const urlObj = new URL(url);
        for (const param of removeParams) {
            urlObj.searchParams.delete(param);
        }
        if (!display) {
            return urlObj.toString();
        }
        // Return URL without protocol
        return urlObj.host + (urlObj.pathname === '/' && !urlObj.search ? '' : urlObj.pathname) + (urlObj.search ? urlObj.search : '');
    }
}<commit_msg>Readded hash to cleaned tracked links in admin<commit_after>import Service from '@ember/service';

export default class UtilsService extends Service {
    downloadFile(url) {
        let iframe = document.getElementById('iframeDownload');

        if (!iframe) {
            iframe = document.createElement('iframe');
            iframe.id = 'iframeDownload';
            iframe.style.display = 'none';
            document.body.append(iframe);
        }

        iframe.setAttribute('src', url);
    }

    /**
     * Remove tracking parameters from a URL
     * @param {string} url 
     * @param {boolean} [display] Set to true to remove protocol and hash from the URL
     * @returns 
     */
    cleanTrackedUrl(url, display = false) {
        // Remove our own querystring parameters and protocol
        const removeParams = ['rel', 'attribution_id', 'attribution_type'];
        const urlObj = new URL(url);
        for (const param of removeParams) {
            urlObj.searchParams.delete(param);
        }
        if (!display) {
            return urlObj.toString();
        }
        // Return URL without protocol
        return urlObj.host + (urlObj.pathname === '/' && !urlObj.search ? '' : urlObj.pathname) + (urlObj.search ? urlObj.search : '') + (urlObj.hash ? urlObj.hash : '');
    }
}
{'fraction_non_alphanumeric': 0.11988993710691824, 'fraction_numerical': 0.0, 'mean_word_length': 2.2966321243523318, '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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4419584', 'n_tokens_mistral': 711, 'n_tokens_neox': 666, 'n_words': 187}