<commit_before><?php

namespace aharen\Language;

use Illuminate\Support\ServiceProvider;
use Language;

class LanguageServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        $this->publishes([
            __DIR__ . '/../../migrations/' => base_path('/database/migrations'),
            __DIR__ . '/../../seeds/'      => base_path('/database/seeds'),
            __DIR__ . '/../../config/'     => base_path('/config'),
        ]);
    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        if (!\App::runningInConsole()) {
            $language_segment = \Request::segment(1);
            Language::validate($language_segment);
        }
    }
}
<commit_msg>Bugfix: if language segment is null, send to default locale<commit_after><?php

namespace aharen\Language;

use Illuminate\Support\ServiceProvider;
use Language;

class LanguageServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        $this->publishes([
            __DIR__ . '/../../migrations/' => base_path('/database/migrations'),
            __DIR__ . '/../../seeds/'      => base_path('/database/seeds'),
            __DIR__ . '/../../config/'     => base_path('/config'),
        ]);
    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        if (!\App::runningInConsole()) {
            $language_segment = \Request::segment(1);
            if ($language_segment === null) {
                return redirect(config('app.locale'))->send();
            }
            Language::validate($language_segment);
        }
    }
}

{'fraction_non_alphanumeric': 0.1531869309051955, 'fraction_numerical': 0.0010712372790573112, 'mean_word_length': 1.9096573208722742, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, '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': '5145671', 'n_tokens_mistral': 501, 'n_tokens_neox': 504, 'n_words': 102}