<commit_before>'use strict';

let util = require('util');

/**
 * This Controller is for building the response
 */
let FilePathBuilderService = function() {

    /**
     *
     * @param method
     * @param url
     * @param queryString
     * @returns {Array}
     * @private
     */
    function _generatePaths(method, url, queryString) {
        let urls = [];

        let request = url.split('?');
        let path = request[0];
        // TODO: Gestion des paramètres dans la recherche de fichiers
        let parameters = url[1].split('&');
        let allParts = path.split('/');

        // method.json
        {
            let url1 = allParts.join('/') + '/' + method + '\\.*';
            urls.push(url1);
        }

        // ../method_lastElement.json
        // ../../method_beforeLastElement_lastElement.json
        // etc.
        let partsCount = allParts.length;
        for(let p=1; p <= (partsCount-1); ++p) {
            let pathParts = [];
            let fileBodyName = [method];
            let fileExtensionName = '\\.*';
            for(let i=0; i<allParts.length; ++i) {
                if(i < allParts.length - (p)) {
                    pathParts.push(allParts[i]);
                } else {
                    fileBodyName.push(allParts[i]);
                }
            }
            let url = pathParts.join('/') + '/' + fileBodyName.join('_') + fileExtensionName;
            urls.push(url);
        }

        // ../@default/method.json
        // ../../@default/method_lastElement.json<commit_msg>Ajout de commentaire sur pathbuilder<commit_after>'use strict';

let util = require('util');

/**
 * This Controller is for building the response
 */
let FilePathBuilderService = function() {

    /**
     *
     * @param method
     * @param url
     * @param queryString
     * @returns {Array}
     * @private
     */
    function _generatePaths(method, url, queryString) {
        
        let urls = [];

        // Remove the parameters for building paths (at the moment)
        let request = url.split('?');
        let path = request[0];
        
        // @TODO Use parameters to build more paths
        let parameters = request[1].split('&');
        
        // Let's split the path to work with it
        let allParts = path.split('/');

        // method.json
        {
            let url1 = allParts.join('/') + '/' + method + '\\.*';
            urls.push(url1);
        }

        // ../method_lastElement.json
        // ../../method_beforeLastElement_lastElement.json
        // etc.
        let partsCount = allParts.length;
        for(let p=1; p <= (partsCount-1); ++p) {
            let pathParts = [];
            let fileBodyName = [method];
            let fileExtensionName = '\\.*';
            for(let i=0; i<allParts.length; ++i) {
                if(i < allParts.length - (p)) {
                    pathParts.push(allParts[i]);
                } else {
                    fileBodyName.push(allParts[i]);
                }
            }
            let url = pathParts.join('/') + '/' + fileBodyName.join('_') + fileExtensionName;
            urls.push(url);
        }

        // ../@default/method.json
        // ../../@default/method_lastElement.json
{'fraction_non_alphanumeric': 0.14972101673899565, 'fraction_numerical': 0.0043397396156230625, 'mean_word_length': 1.5270164447924823, 'pattern_counts': {'":': 0, '<': 9, '<?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': '515643', 'n_tokens_mistral': 936, 'n_tokens_neox': 908, 'n_words': 204}