<commit_before>var url = require("url");
var path = require("path");
/**
 * 路由调配
 * @type {Object}
 */
var Dispatcher = module.exports = Class(function(){
    return {
        init: function(http){
            this.http = http;
        },
        run: function(){
            var group = "";
            var controller = "";
            var action = "";
            tag("path_info", this.http);
            var pathname = this.http.pathname;
            //URL后缀
            var extname = path.extname(pathname);
            //判断URL后缀
            if (extname == C('url_html_suffix')) {
                pathname = path.dirname(pathname) + "/" + path.basename(pathname, C('url_html_suffix'));
            }; 
            pathname = pathname.split("/").filter(function(item){
                item = item.trim();
                if (item) {
                    return item;
                };
            }).join("/");
            //去除pathname前缀
            if (C('pathname_prefix') && pathname.indexOf(C('pathname_prefix')) === 0) {
                pathname = pathname.substr(C('pathname_prefix').length);
            };
            this.http.pathname = pathname;
            //是否使用自定义路由
            if (!this.routerCheck()) {
                var paths = pathname.split("/");
                var groupList = (C('app_group_list') || []).map(function(item){
                    return item.toLowerCase();
                });
                if (groupList.length) {
                    if (groupList.indexOf((paths[0]+"").toLowerCase()) > -1) {
                        group = paths.shift();
                    };
                };
                var deny = C('app_group_deny') || [];
                if (group && deny.length) {
                    if (deny.indexOf(_group) > -1) {
                        throw_error("favicon.ico", this.http);
                    };
                };
                controller = paths.shift();
                action = paths.shift();
                if (paths.length) {
                    for(var i = 0,length = Math.ceil(paths.length)/2; i < length; i++){
                        this.http.get[paths[i * 2]] = paths[i * 2 + 1] || "";
                    }
                };
                this.http.group = Dispatcher.getGroup(group);
                this.http.controller = Dispatcher.getController(controller);
                this.http.action = Dispatcher.getAction(action);
            };
            return true;
        },
        /**
         * 自定义路由检测
         * @return {[type]} [description]<commit_msg>update #19<commit_after>var url = require("url");
var path = require("path");
/**
 * 路由调配
 * @type {Object}
 */
var Dispatcher = module.exports = Class(function(){
    return {
        init: function(http){
            this.http = http;
        },
        run: function(){
            var group = "";
            var controller = "";
            var action = "";
            tag("path_info", this.http);
            var pathname = this.http.pathname;
            //URL后缀
            var extname = path.extname(pathname);
            //判断URL后缀
            if (extname == C('url_html_suffix')) {
                pathname = path.dirname(pathname) + "/" + path.basename(pathname, C('url_html_suffix'));
            }; 
            pathname = pathname.split("/").filter(function(item){
                item = item.trim();
                if (item) {
                    return item;
                };
            }).join("/");
            //去除pathname前缀
            if (C('pathname_prefix') && pathname.indexOf(C('pathname_prefix')) === 0) {
                pathname = pathname.substr(C('pathname_prefix').length);
            };
            this.http.pathname = pathname;
            //是否使用自定义路由
            if (!this.routerCheck()) {
                var paths = pathname.split("/");
                var groupList = (C('app_group_list') || []).map(function(item){
                    return item.toLowerCase();
                });
                if (groupList.length) {
                    if (groupList.indexOf((paths[0] + "").toLowerCase()) > -1) {
                        group = paths.shift();
                    };
                };
                var deny = C('app_group_deny') || [];
                if (group && deny.length) {
                    if (deny.indexOf(_group) > -1) {
                        throw_error("favicon.ico", this.http);
                    };
                };
                controller = paths.shift();
                action = paths.shift();
                if (paths.length) {
                    for(var i = 0,length = Math.ceil(paths.length)/2; i < length; i++){
                        this.http.get[paths[i * 2]] = paths[i * 2 + 1] || "";
                    }
                };
                this.http.group = Dispatcher.getGroup(group);
                this.http.controller = Dispatcher.getController(controller);
                this.http.action = Dispatcher.getAction(action);
            };
            return true;
        },
        /**
         * 自定义路由检测
         * @return {[type]} [description]
{'fraction_non_alphanumeric': 0.1457720227584854, 'fraction_numerical': 0.003923876790268786, 'mean_word_length': 1.2497793468667255, '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': '2114346', 'n_tokens_mistral': 1426, 'n_tokens_neox': 1364, 'n_words': 243}