Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex used in JavascriptRenderer.php overrides/negates route_domain parameter #1637

Open
chrischi1989 opened this issue Jul 29, 2024 · 1 comment

Comments

@chrischi1989
Copy link

chrischi1989 commented Jul 29, 2024

Hi there

I need to load the Debugbar from a sub domain because that's where my Laravel instance is running and my system on my top-level domain is querying Laravel via Guzzle. Maybe it sound kinda weird but that's how it is.

I set the route_domain parameter in the debugbar.php and cleared & cached the config for Laravel. After reloading my system I saw that the injected HTML still tries to load the debugbar assets from my top level domain.

So I did some testing and debugging and found out that the Regex used in these lines in the JavascriptRenderer.php is removing the domain completely, resulting in $cssRoute only be filled with /_debugbar/assets/[...] and NOT including the route_domain given via the config file:

$cssRoute = preg_replace('/\Ahttps?:\/\/[^\/]+/', '', route('debugbar.assets.css', [

$jsRoute = preg_replace('/\Ahttps?:\/\/[^\/]+/', '', route('debugbar.assets.js', [

Tests & Debugging

I did a quick test, setting some.domain as the route_domain parameter. Then I did some tinkering in the JavascriptRenderer with the old regex and watched Xdebug while refreshing my system. These are the results:

grafik

I also did some tests with regex101.com

Current regex

grafik

Old regex (don't know when this was changed)

grafik

As you can see the current used regex matches the whole domain and therefor the preg_replace will remove it entirely from the string.

I don't think this is intended behavior and it would be cool if you guys could take a look at this.

Greetings

@parallels999
Copy link
Contributor

#1555

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants