<commit_before>import chai from 'chai';
import forward from '../src/index.js';
const expect = chai.expect;
import TestServer from './server';
import request from 'supertest';
const local = new TestServer();
// const base = `http://${local.hostname}:${local.port}/`;
const urls = [
    'https://www.gome.com.cn/',
    'https://www.gomeplus.com/'
]
commonTest({ description: 'null option should start normally', urls });
const productionOption = {
    filterHtml(html) {
        return html.replace(/<script[\S]+?uba-sdk[\S]+?<\/script>/, '').replace(/top\.location/g, '{}');
    },
    filterCookie(cookie) {
        return cookie.replace(/DataPlatform.*?=.+?;/gi, '')
    },
    filterStatic(content) {
        return content && content.replace(/\.assign\(([^,]+?)\)/g, '.$assign($1)').replace(/top\.location/g, '{}');
    },
    prefix: '/databp',
    script: function _external(pageUrl, platform, origin, prefix) {
        window.$pageUrl = pageUrl;
        window.$platform = platform;
        window.location.$assign = function(url) {
            let newurl;
            if (/https?:\/\//.test(url)) {
                // do noting
                newurl = url;
            } else {
                newurl = '/databp/html?m=' + platform + '&url=' + encodeURIComponent(pageUrl.replace(/\/$/, '') + '/' + url.replace(/^\//, ''));
            }
            window.location.assign(newurl);
        }
    }
}
commonTest({ description: 'production option should work', urls, option: productionOption});

function commonTest({ description, option, urls }) {
    describe(description, function() {
        this.timeout(5000);
        // empty option
        let app = local.app;
        forward(option)(app);
        it('request /html should be bad request', function(done) {
            request(app)
                .get('/html')
                .expect(function(res) {
                    res.text.includes('html');
                })
                .expect(400, done);
        });
        it('request /ajax should be bad request', function(done) {
            request(app)
                .get('/ajax')
                .expect(function(res) {<commit_msg>increace test timeout again<commit_after>import chai from 'chai';
import forward from '../src/index.js';
const expect = chai.expect;
import TestServer from './server';
import request from 'supertest';
const local = new TestServer();
// const base = `http://${local.hostname}:${local.port}/`;
const urls = [
    'https://www.gome.com.cn/',
    'https://www.gomeplus.com/'
]
commonTest({ description: 'null option should start normally', urls });
const productionOption = {
    filterHtml(html) {
        return html.replace(/<script[\S]+?uba-sdk[\S]+?<\/script>/, '').replace(/top\.location/g, '{}');
    },
    filterCookie(cookie) {
        return cookie.replace(/DataPlatform.*?=.+?;/gi, '')
    },
    filterStatic(content) {
        return content && content.replace(/\.assign\(([^,]+?)\)/g, '.$assign($1)').replace(/top\.location/g, '{}');
    },
    prefix: '/databp',
    script: function _external(pageUrl, platform, origin, prefix) {
        window.$pageUrl = pageUrl;
        window.$platform = platform;
        window.location.$assign = function(url) {
            let newurl;
            if (/https?:\/\//.test(url)) {
                // do noting
                newurl = url;
            } else {
                newurl = '/databp/html?m=' + platform + '&url=' + encodeURIComponent(pageUrl.replace(/\/$/, '') + '/' + url.replace(/^\//, ''));
            }
            window.location.assign(newurl);
        }
    }
}
commonTest({ description: 'production option should work', urls, option: productionOption});

function commonTest({ description, option, urls }) {
    describe(description, function() {
        this.timeout(15000);
        // empty option
        let app = local.app;
        forward(option)(app);
        it('request /html should be bad request', function(done) {
            request(app)
                .get('/html')
                .expect(function(res) {
                    res.text.includes('html');
                })
                .expect(400, done);
        });
        it('request /ajax should be bad request', function(done) {
            request(app)
                .get('/ajax')
                .expect(function(res) {
{'fraction_non_alphanumeric': 0.17912520249942143, 'fraction_numerical': 0.003934274473501504, 'mean_word_length': 2.1183261183261184, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, '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': '6220795', 'n_tokens_mistral': 1269, 'n_tokens_neox': 1229, 'n_words': 259}