spatie / laravel-error-solutions

Display solutions on the Laravel error page
https://spatie.be/docs/laravel-error-solutions
MIT License
71 stars 6 forks source link

Ai powered solution sends an error #4

Open bestmomo opened 3 months ago

bestmomo commented 3 months ago

What happened?

I just installed package and complement for AI powered solution. When I create an issue to test it I get :

Capture d'écran 2024-07-21 125216

I had to change the links function like this to make it work for me:

public function links(): array
{
    $rawText = Str::finish($this->rawText, 'ENDLINKS');

    $textLinks = $this->between('LINKS', 'ENDLINKS', $rawText);

    $textLinks = explode(PHP_EOL, $textLinks);

    $links = [];

    foreach ($textLinks as $textLink) {
        $textLink = str_replace('\\', '\\\\', $textLink);
        $textLink = str_replace('\\\\\\', '\\\\', $textLink);

        $decodedLink = json_decode($textLink, true);

        if ($decodedLink !== null) {
            $links[$decodedLink['title']] = $decodedLink['url'];
        }
    }

    return $links;
}

How to reproduce the bug

When I install the package in my project and use it with AI powered

Package Version

1.0

PHP Version

8.2.14

Laravel Version

11.14

Which operating systems does with happen with?

Windows

Notes

No response

freekmurze commented 3 months ago

I'd accept a PR that fixes this.

SecurID commented 2 months ago

Isn't that already resolved by https://github.com/spatie/error-solutions/pull/9?