<commit_before>const fs = require("fs");
const TOSManager = require("./TOSManager");

class ResponseFactory {
    constructor(app, req, res, root = "") {
        this.app = app;
        this.req = req;
        this.res = res;
        this.root = root;
    }

    sendRenderedResponse(template, data = null, mimeType = "text/html") {
        var sendData = this.getAutomaticTemplateData();
        if (data) sendData = Object.assign({}, sendData, data);
        return this.res.header("Content-Type", mimeType).render(this.root + template, sendData);
    }

    getAutomaticTemplateData() {
        var resources = this.req.place.moduleManager.getResourcesFromModules(this.req);
        var redirectURLPart = this.req.path == "/signin" || this.req.path == "/signup" ? "" : encodeURIComponent(this.req.baseUrl.substr(1) + "/" + this.req.url.substr(1));
        var path = this.req.baseUrl + this.req.path;
        var data = { url: this.req.url, path: path, config: this.app.config, fs: fs, renderCaptcha: () => this.app.recaptcha.render(), redirectURLPart: redirectURLPart, moduleManager: this.req.place.moduleManager, resources: resources, req: this.req, res: this.res, TOSManager: TOSManager };
        if (typeof this.req.user !== undefined && this.req.user) data.user = this.req.user;
        return data;
    }
}

ResponseFactory.prototype = Object.create(ResponseFactory.prototype);

module.exports = ResponseFactory;<commit_msg>Fix redirect URLs for some pages<commit_after>const fs = require("fs");
const TOSManager = require("./TOSManager");

class ResponseFactory {
    constructor(app, req, res, root = "") {
        this.app = app;
        this.req = req;
        this.res = res;
        this.root = root;
    }

    sendRenderedResponse(template, data = null, mimeType = "text/html") {
        var sendData = this.getAutomaticTemplateData();
        if (data) sendData = Object.assign({}, sendData, data);
        return this.res.header("Content-Type", mimeType).render(this.root + template, sendData);
    }

    getAutomaticTemplateData() {
        var resources = this.req.place.moduleManager.getResourcesFromModules(this.req);
        var routerPath = this.req.baseUrl.substr(1);
        if(routerPath.length > 0) routerPath += "/";
        var redirectURLPart = this.req.path == "/signin" || this.req.path == "/signup" ? "" : encodeURIComponent(routerPath + this.req.url.substr(1));
        var path = this.req.baseUrl + this.req.path;
        var data = { url: this.req.url, path: path, config: this.app.config, fs: fs, renderCaptcha: () => this.app.recaptcha.render(), redirectURLPart: redirectURLPart, moduleManager: this.req.place.moduleManager, resources: resources, req: this.req, res: this.res, TOSManager: TOSManager };
        if (typeof this.req.user !== undefined && this.req.user) data.user = this.req.user;
        return data;
    }
}

ResponseFactory.prototype = Object.create(ResponseFactory.prototype);

module.exports = ResponseFactory;
{'fraction_non_alphanumeric': 0.1454055873443285, 'fraction_numerical': 0.001682935038707506, 'mean_word_length': 3.3386861313868614, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '321659', 'n_tokens_mistral': 901, 'n_tokens_neox': 899, 'n_words': 194}