<commit_before>'use strict';

const through2 = tars.packages.through2;
const path = require('path');
const Buffer = require('buffer').Buffer;

/**
 * Generate static path for pages
 */
module.exports = function generateStaticPath() {

    return through2.obj(function (file, enc, callback) {
        // Get all directories array for current page from page directory
        const directoriesArray = path.parse(file.relative).dir.split(path.sep);
        // Generate static path as '../' as many times, as directories array length + tars.config.staticPrefix
        const pageDepth = directoriesArray.map(value => { if (value) return '../' })
        const staticPath = pageDepth.join('') + tars.config.staticPrefix;
        let newPageContent = file.contents.toString().replace(
            /%=staticPrefix=%|%=static=%|__static__/g, staticPath
        );

        newPageContent = newPageContent.replace(
            /xlink:href="(.*)"/gim, (str, $1) => `xlink:href="${pageDepth.join('') + $1}"`
        );

        file.contents = new Buffer(newPageContent);

        this.push(file); // eslint-disable-line no-invalid-this

        return callback();
    }, callback =>  callback());
}<commit_msg>HOTFIX: fix bug with injected svg in page<commit_after>'use strict';

const through2 = tars.packages.through2;
const path = require('path');
const Buffer = require('buffer').Buffer;

/**
 * Generate static path for pages
 */
module.exports = function generateStaticPath() {

    return through2.obj(function (file, enc, callback) {
        // Get all directories array for current page from page directory
        const directoriesArray = path.parse(file.relative).dir.split(path.sep);
        // Generate static path as '../' as many times, as directories array length + tars.config.staticPrefix
        const pageDepth = directoriesArray.map(value => { if (value) return '../' })
        const staticPath = pageDepth.join('') + tars.config.staticPrefix;
        let newPageContent = file.contents.toString().replace(
            /%=staticPrefix=%|%=static=%|__static__/g, staticPath
        );

        if (tars.config.svg.active && tars.config.svg.workflow === 'symbols' &&
            tars.config.svg.symbolsConfig.loadingType === 'separate-file-with-link') {
            newPageContent = newPageContent.replace(
                /xlink:href="(.*)"/gim, (str, $1) => `xlink:href="${pageDepth.join('') + $1}"`
            );
        }

        file.contents = new Buffer(newPageContent);

        this.push(file); // eslint-disable-line no-invalid-this

        return callback();
    }, callback =>  callback());
}
{'fraction_non_alphanumeric': 0.14749713412304166, 'fraction_numerical': 0.0038211692777990066, 'mean_word_length': 2.9368421052631577, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '818106', 'n_tokens_mistral': 748, 'n_tokens_neox': 718, 'n_words': 175}