<commit_before>
(function($) {

    initLanguageSwitcher = function()
    {
        $("#language-switcher button").click(function(e) {
            var switchToLang = '/' + $(this).attr("id").replace(/^language-switcher-/, "");

            if (lang != switchToLang) {
                var langRegex = new RegExp('/' + lang);

                //console.log(location.pathname, location.pathname.replace(langRegex, switchToLang));
                var newHref = location.protocol
                        + "//" + location.host
                        + location.pathname.replace(langRegex, switchToLang)
                        + location.search;
                //console.log(newHref);
                location.href = newHref;
            }
        });
    };

    $(function() {
        initLanguageSwitcher();
    });

})(jQuery);<commit_msg>[Core] fixes language-switcher when using a basepath<commit_after>
(function($) {

    initLanguageSwitcher = function()
    {
        $("#language-switcher button").click(function(e) {
            var switchToLang = '/' + $(this).attr("id").replace(/^language-switcher-/, "");

            if (lang != switchToLang) {
                var langRegex = new RegExp('/' + lang + '($|\/)');

                //console.log(location.pathname, location.pathname.replace(langRegex, switchToLang + '$1'));
                var newHref = location.protocol
                        + "//" + location.host
                        + location.pathname.replace(langRegex, switchToLang)
                        + location.search;
                //console.log(newHref);
                location.href = newHref;
            }
        });
    };

    $(function() {
        initLanguageSwitcher();
    });

})(jQuery);
{'fraction_non_alphanumeric': 0.15198618307426598, 'fraction_numerical': 0.0005757052389176742, 'mean_word_length': 1.657492354740061, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1864588', 'n_tokens_mistral': 478, 'n_tokens_neox': 462, 'n_words': 72}