<commit_before>(function(mifosX) {
    var defineHeaders = function($httpProvider , $translateProvider, ResourceFactoryProvider ,HttpServiceProvider) {
        var mainLink = getLocation(window.location.href);
        var baseApiUrl = "https://demo.openmf.org";
        var host = "";
        //accessing from openmf server
        if (mainLink.hostname.indexOf('openmf.org') >= 0) {
            var hostname = window.location.hostname;
            console.log('hostname---'+hostname);
            domains = hostname.split('.');
            console.log('domains---'+domains);
            // For multi tenant hosting
            if (domains[0] == "demo") {
                $httpProvider.defaults.headers.common['X-Mifos-Platform-TenantId'] = 'default';
                ResourceFactoryProvider.setTenantIdenetifier('default');
                console.log("demo server",domains[0]);
            } else {
                $httpProvider.defaults.headers.common['X-Mifos-Platform-TenantId'] = domains[0];
                ResourceFactoryProvider.setTenantIdenetifier(domains[0]);
                console.log("other than demo server", domains[0]);

            }
            host = mainLink.hostname;
            console.log('hostname from mainLink = ',host);
        } 
        //accessing from a file system or other servers
        else {
            if (mainLink.hostname != "") {
                baseApiUrl = "https://"+mainLink.hostname+(mainLink.port ? ':'+mainLink.port : '');
            }
            
            if(QueryParameters["baseApiUrl"]) { 
                baseApiUrl = QueryParameters["baseApiUrl"];
            }
            var queryLink = getLocation(baseApiUrl);
            host = "https://"+queryLink.hostname+(queryLink.port ? ':'+queryLink.port : '');
            // Angularjs strips everything after colon(:) so we are appending port number again
            // follow this link for more info https://github.com/angular/angular.js/issues/1243 
            if (queryLink.port) {              
                host = host.concat('\:'+queryLink.port);
            };
            console.log('hostname from baseApiUrl = ',host);

            $httpProvider.defaults.headers.common['X-Mifos-Platform-TenantId'] = 'default';
            ResourceFactoryProvider.setTenantIdenetifier('default');
            if(QueryParameters["tenantIdentifier"]) {
                $httpProvider.defaults.headers.common['X-Mifos-Platform-TenantId'] = QueryParameters["tenantIdentifier"];
                ResourceFactoryProvider.setTenantIdenetifier(QueryParameters["tenantIdentifier"]);
            }
        }

        ResourceFactoryProvider.setBaseUrl(host);
        HttpServiceProvider.addRequestInterceptor('demoUrl', function(config) {
          return _.extend(config, {url: host + config.url });
        });

        // Enable CORS! (see e.g. http://enable-cors.org/)
        $httpProvider.defaults.useXDomain = true;
        delete $httpProvider.defaults.headers.common['X-Requested-With'];

        //Set headers
        $httpProvider.defaults.headers.common['Content-Type'] = 'application/json; charset=utf-8';

        // Configure i18n and preffer language
              //$translateProvider.translations('en', translationsEN);
              //$translateProvider.translations('de', translationsDE);

        $translateProvider.useStaticFilesLoader({
              prefix: 'global-translations/locale-',
              suffix: '.json'
        });

        $translateProvider.preferredLanguage('en');<commit_msg>port number is not escaped properly(fixed)<commit_after>(function(mifosX) {
    var defineHeaders = function($httpProvider , $translateProvider, ResourceFactoryProvider ,HttpServiceProvider) {
        var mainLink = getLocation(window.location.href);
        var baseApiUrl = "https://demo.openmf.org";
        var host = "";
        var portNumber = "";
        //accessing from openmf server
        if (mainLink.hostname.indexOf('openmf.org') >= 0) {
            var hostname = window.location.hostname;
            console.log('hostname---'+hostname);
            domains = hostname.split('.');
            console.log('domains---'+domains);
            // For multi tenant hosting
            if (domains[0] == "demo") {
                $httpProvider.defaults.headers.common['X-Mifos-Platform-TenantId'] = 'default';
                ResourceFactoryProvider.setTenantIdenetifier('default');
                console.log("demo server",domains[0]);
            } else {
                $httpProvider.defaults.headers.common['X-Mifos-Platform-TenantId'] = domains[0];
                ResourceFactoryProvider.setTenantIdenetifier(domains[0]);
                console.log("other than demo server", domains[0]);

            }
            host = mainLink.hostname;
            console.log('hostname from mainLink = ',host);
        } 
        //accessing from a file system or other servers
        else {
            if (mainLink.hostname != "") {
                baseApiUrl = "https://"+mainLink.hostname+(mainLink.port ? ':'+mainLink.port : '');
            }
            
            if (QueryParameters["baseApiUrl"]) { 
                baseApiUrl = QueryParameters["baseApiUrl"];
            }
            var queryLink = getLocation(baseApiUrl);
            host = "https://"+queryLink.hostname+(queryLink.port ? ':'+queryLink.port : '');
            portNumber = queryLink.port;

            $httpProvider.defaults.headers.common['X-Mifos-Platform-TenantId'] = 'default';
            ResourceFactoryProvider.setTenantIdenetifier('default');
            if(QueryParameters["tenantIdentifier"]) {
                $httpProvider.defaults.headers.common['X-Mifos-Platform-TenantId'] = QueryParameters["tenantIdentifier"];
                ResourceFactoryProvider.setTenantIdenetifier(QueryParameters["tenantIdentifier"]);
            }
        }

        // Angularjs strips everything after colon(:) so we are appending port number again
        // follow this link for more info https://github.com/angular/angular.js/issues/1243 
        if (portNumber && portNumber != "") {              
            host = host.concat(':'+portNumber);
        };
        ResourceFactoryProvider.setBaseUrl(host);
        HttpServiceProvider.addRequestInterceptor('demoUrl', function(config) {
            if (portNumber && portNumber != ""){
                host = host.replace(':'+portNumber, "");
            }
          return _.extend(config, {url: host + config.url });
        });

        // Enable CORS! (see e.g. http://enable-cors.org/)
        $httpProvider.defaults.useXDomain = true;
        delete $httpProvider.defaults.headers.common['X-Requested-With'];

        //Set headers
        $httpProvider.defaults.headers.common['Content-Type'] = 'application/json; charset=utf-8';

        // Configure i18n and preffer language
              //$translateProvider.translations('en', translationsEN);
              //$translateProvider.translations('de', translationsDE);

        $translateProvider.useStaticFilesLoader({
              prefix: 'global-translations/locale-',
              suffix: '.json'
        });

        $translateProvider.preferredLanguage('en');
{'fraction_non_alphanumeric': 0.13080990815474533, 'fraction_numerical': 0.0036181463957695517, 'mean_word_length': 2.2228699551569506, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 8, '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': '2237640', 'n_tokens_mistral': 1882, 'n_tokens_neox': 1835, 'n_words': 311}