laravel-debugbar
laravel-debugbar copied to clipboard
Regex used in JavascriptRenderer.php overrides/negates route_domain parameter
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:
https://github.com/barryvdh/laravel-debugbar/blob/bd8edca124f84d14203b29698f8f204c8eabc960/src/JavascriptRenderer.php#L52
https://github.com/barryvdh/laravel-debugbar/blob/bd8edca124f84d14203b29698f8f204c8eabc960/src/JavascriptRenderer.php#L57
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:
I also did some tests with regex101.com
Current regex
Old regex (don't know when this was changed)
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