<commit_before>/**
 * This interceptor catch http 200 responses body that
 * contain a specific string portion. If the portion is found,
 * then the redirection happens.
 */

(function () {
    'use strict';

    angular
        .module('httpInterceptorModule', [])
        .factory('InterceptorConfigFactory', InterceptorConfigFactory)
        .config(appConfiguration);

    function InterceptorConfigFactory() {
        var errorStringSection = '<meta';

        return {
            redirectUrl: 'http://redirect.me',
            setRedirectUrl: function (url) {
                this.redirectUrl = url;

                return this.redirectUrl;
            },
            getStringToCheck: function () {
                return errorStringSection;
            }
        };
    }

    function appConfiguration($httpProvider) {
        $httpProvider.interceptors.push(interceptorHandler);
    }

    // we dont want ot call indexOf on something that's not a string
    function isString(obj) {
        return (Object.prototype.toString.call(obj) === '[object String]');
    }

    function interceptorHandler($q, $window, InterceptorConfigFactory) {
        return {
            request: function (config) {
                console.log('config ->', config);

                return config;
            },
            response: function (response) {
                console.log('response ->', response);

                if (isString(response.data) && !!response.data &&
                    -1 !== response.data.indexOf(InterceptorConfigFactory.getStringToCheck())) {
                    $window.location.href = InterceptorConfigFactory.redirectUrl;
                }

                return response;
            },
            responseError: function (rejection) {
                return $q.reject(rejection);
            }
        };
    }
})();<commit_msg>Rename vars<commit_after>/**
 * This interceptor catch http 200 responses body that
 * contain a specific string portion. If the portion is found,
 * then the redirection happens.
 */

(function () {
    'use strict';

    angular
        .module('httpInterceptorModule', [])
        .factory('InterceptorConfigFactory', InterceptorConfigFactory)
        .config(appConfiguration);

    function InterceptorConfigFactory() {
        var subStringToFind = '<meta';

        return {
            redirectUrl: 'http://redirect.me',
            setRedirectUrl: function (url) {
                this.redirectUrl = url;

                return this.redirectUrl;
            },
            getSubStringToFind: function () {
                return subStringToFind;
            }
        };
    }

    function appConfiguration($httpProvider) {
        $httpProvider.interceptors.push(interceptorHandler);
    }

    // we dont want ot call indexOf on something that's not a string
    function isString(obj) {
        return (Object.prototype.toString.call(obj) === '[object String]');
    }

    function interceptorHandler($q, $window, InterceptorConfigFactory) {
        return {
            request: function (config) {
                console.log('config ->', config);

                return config;
            },
            response: function (response) {
                console.log('response ->', response);

                if (isString(response.data) && !!response.data &&
                    -1 !== response.data.indexOf(InterceptorConfigFactory.getSubStringToFind())) {
                    $window.location.href = InterceptorConfigFactory.redirectUrl;
                }

                return response;
            },
            responseError: function (rejection) {
                return $q.reject(rejection);
            }
        };
    }
})();
{'fraction_non_alphanumeric': 0.10650887573964497, 'fraction_numerical': 0.002151694459386767, 'mean_word_length': 1.8651771956856702, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '5818970', 'n_tokens_mistral': 928, 'n_tokens_neox': 872, 'n_words': 205}