<commit_before><?php namespace GeneaLabs\LaravelCasts\Http\Middleware;

use Closure;

class AssetInjection
{
    public function handle($request, Closure $next)
    {
        $response = $next($request);
        $content = $response->content();

        if (preg_match('/<form.*?framework=".*/', $content)) {
            return $response->setContent(str_replace(
                '</body>',
                '<script src="' . asset('genealabs-laravel-casts/app.js') . '"></script></body>',
                $content
            ));
        }

        return $response;
    }
}<commit_msg>WIP - fix middleware<commit_after><?php namespace GeneaLabs\LaravelCasts\Http\Middleware;

use Closure;

class AssetInjection
{
    public function handle($request, Closure $next)
    {
        $response = $next($request);
        $content = $response->content();

        if (preg_match('/<form/', $content)) {
            return $response->setContent(str_replace(
                '</body>',
                '<script src="' . asset('genealabs-laravel-casts/app.js') . '"></script></body>',
                $content
            ));
        }

        return $response;
    }
}
{'fraction_non_alphanumeric': 0.16192937123169682, 'fraction_numerical': 0.0, 'mean_word_length': 2.1152815013404824, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '6945402', 'n_tokens_mistral': 353, 'n_tokens_neox': 339, 'n_words': 60}