<commit_before>var querystring = require('querystring');
var fluxex = require('../index');

module.exports = {
    // All current page and location related things stay here.
    // We do not emitChange() in this store because this store should not trigger re-rendering directly.
    // set fluxex.protocol to override default url.protocol
    // set fluxex.hostname to override default url.hostname
    // set fluxex.port to override default url.port
    page: {
        initialize: function () {
            this._set('routing', {});
            this._set('body', {});
            this._set('url', {});
        },

        // Title functions
        handle_UPDATE_TITLE: function (title) {
            this._set('title', title);
        },

        getTitle: function () {
            return this._get('title');
        },

        // Routing functions
        handle_UPDATE_ROUTING: function (routing) {
            this._set('routing', routing);
        },
        getRouteName: function () {
            return this._get('routing').name;
        },
        getRoutingParam: function () {
            return this._get('routing').params || {};
        },

        // Post body functions
        handle_UPDATE_BODY: function (body) {
            this._set('body', body);
        },
        getBody: function () {
            return this._get('body');
        },

        // URL functions
        handle_UPDATE_URL: function (payload) {
            var isPayloadString = ('string' == typeof payload),
                url = isPayloadString ? payload : payload.url,
                host = isPayloadString ? undefined : payload.host,
                M = url.match(/^(?:(https?:)\/\/(([^:/]+)(:[^\/]+)?))?([^#?]*)(\\?[^#]*)?(#.*)?$/),
                N = host ? host.match(/^([^:]+)(:(.+))?$/) : [],
                search = M[6] || '',
                hash = M[7] || '',
                URL = {
                    href: M[5] + search + hash,
                    protocol: fluxex.protocol || M[1] || '',
                    hostname: fluxex.hostname || M[3] || N[1] || '',
                    port: fluxex.port || M[4] || N[3] || '',
                    pathname: M[5] || '',
                    search: search,
                    hash: hash,
                    query: querystring.decode(search.substring(1)) || {}
                };

            URL.host = URL.hostname + ((URL.port !== '') ? (':' + URL.port) : '');

            this._set('url', URL);
        },
        getQuery: function () {
            return this._get('url').query;
        },
        getURL: function (query) {
            var url = this._get('url'),
                mixedSearch = querystring.encode(Object.assign(url.query, query));

            return url.protocol + '//' + url.host + url.pathname + (mixedSearch ? '?' : '') + mixedSearch + url.hash;
        },
        getParam: function () {
            if ('production' !== process.env.NODE_ENV) {
                console.warn('pageStore.getParam() is deplicated, plase rename to pageStore.getParams()');
            }
            return Object.assign({}, this.getRoutingParam(), this.getBody(), this.getQuery());
        },
        getParams: function () {
            return Object.assign({}, this.getRoutingParam(), this.getBody(), this.getQuery());
        }
    },

    // All header > meta related things stay here.
    // We do not emitChange() in this store because this store should not trigger re-rendering directly.
    meta: {
        handle_UPDATE_META: function (meta) {
            this._set('meta', meta);
        },
        getMeta: function () {
            return this._get('meta');
        }
    }
};<commit_msg>IE8 fix<commit_after>var querystring = require('querystring');
var fluxex = require('../index');

module.exports = {
    // All current page and location related things stay here.
    // We do not emitChange() in this store because this store should not trigger re-rendering directly.
    // set fluxex.protocol to override default url.protocol
    // set fluxex.hostname to override default url.hostname
    // set fluxex.port to override default url.port
    page: {
        initialize: function () {
            this._set('routing', {});
            this._set('body', {});
            this._set('url', {});
        },

        // Title functions
        handle_UPDATE_TITLE: function (title) {
            this._set('title', title);
        },

        getTitle: function () {
            return this._get('title');
        },

        // Routing functions
        handle_UPDATE_ROUTING: function (routing) {
            this._set('routing', routing);
        },
        getRouteName: function () {
            return this._get('routing').name;
        },
        getRoutingParam: function () {
            return this._get('routing').params || {};
        },

        // Post body functions
        handle_UPDATE_BODY: function (body) {
            this._set('body', body);
        },
        getBody: function () {
            return this._get('body');
        },

        // URL functions
        handle_UPDATE_URL: function (payload) {
            var isPayloadString = ('string' == typeof payload),
                url = isPayloadString ? payload : payload.url,
                host = isPayloadString ? undefined : payload.host,
                M = url.match(/^(?:(https?:)\/\/(([^:/]+)(:[^\/]+)?))?([^#?]*)(\\?[^#]*)?(#.*)?$/),
                N = host ? host.match(/^([^:]+)(:(.+))?$/) : [],
                search = M[6] || '',
                hash = M[7] || '',
                URL = {
                    href: M[5] + search + hash,
                    protocol: fluxex.protocol || M[1] || '',
                    hostname: fluxex.hostname || M[3] || N[1] || '',
                    port: fluxex.port || M[4] || N[3] || '',
                    pathname: M[5] || '',
                    search: search,
                    hash: hash,
                    query: querystring.decode(search.substring(1)) || {}
                };

            URL.host = URL.hostname + ((URL.port !== '') ? (':' + URL.port) : '');

            this._set('url', URL);
        },
        getQuery: function () {
            return this._get('url').query;
        },
        getURL: function (query) {
            var url = this._get('url'),
                mixedSearch = querystring.encode(Object.assign(url.query, query));

            return url.protocol + '//' + url.host + url.pathname + (mixedSearch ? '?' : '') + mixedSearch + url.hash;
        },
        getParam: function () {
            if ('production' !== process.env.NODE_ENV) {
                if (console && console.warn) {
                    console.warn('pageStore.getParam() is deplicated, plase rename to pageStore.getParams()');
                }
            }
            return Object.assign({}, this.getRoutingParam(), this.getBody(), this.getQuery());
        },
        getParams: function () {
            return Object.assign({}, this.getRoutingParam(), this.getBody(), this.getQuery());
        }
    },

    // All header > meta related things stay here.
    // We do not emitChange() in this store because this store should not trigger re-rendering directly.
    meta: {
        handle_UPDATE_META: function (meta) {
            this._set('meta', meta);
        },
        getMeta: function () {
            return this._get('meta');
        }
    }
};
{'fraction_non_alphanumeric': 0.16127285037237643, 'fraction_numerical': 0.002843601895734597, 'mean_word_length': 1.652064631956912, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1318234', 'n_tokens_mistral': 2041, 'n_tokens_neox': 1966, 'n_words': 456}