Skip to content

Commit 091b37e

Browse files
mykiwifabpot
authored andcommitted
[WebProfilerBundle] Fix regexp
1 parent 8054629 commit 091b37e

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/Configuration.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function getConfigTreeBuilder()
4545
->end()
4646
->end()
4747
->booleanNode('intercept_redirects')->defaultFalse()->end()
48-
->scalarNode('excluded_ajax_paths')->defaultValue('^/bundles|^/_wdt')->end()
48+
->scalarNode('excluded_ajax_paths')->defaultValue('^/(app(_[\\w]+)?\\.php/)?_wdt')->end()
4949
->end()
5050
;
5151

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig

+11-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,17 @@
203203
var self = this;
204204
205205
/* prevent logging AJAX calls to static and inline files, like templates */
206-
if (url.substr(0, 1) === '/' && !url.match(new RegExp("{{ excluded_ajax_paths }}"))) {
206+
var path = url;
207+
if (url.substr(0, 1) === '/') {
208+
if (0 === url.indexOf('{{ app.request.basePath|e('js') }}')) {
209+
path = url.substr({{ app.request.basePath|length }});
210+
}
211+
}
212+
else if (0 === url.indexOf('{{ (app.request.schemeAndHttpHost ~ app.request.basePath)|e('js') }}')) {
213+
path = url.substr({{ (app.request.schemeAndHttpHost ~ app.request.basePath)|length }});
214+
}
215+
216+
if (path.substr(0, 1) === '/' && !path.match(new RegExp({{ excluded_ajax_paths|json_encode|raw }}))) {
207217
var stackElement = {
208218
loading: true,
209219
error: false,

src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/ConfigurationTest.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ public function testConfigTree($options, $results)
3131
public function getDebugModes()
3232
{
3333
return array(
34-
array(array(), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/bundles|^/_wdt')),
35-
array(array('intercept_redirects' => true), array('intercept_redirects' => true, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/bundles|^/_wdt')),
36-
array(array('intercept_redirects' => false), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/bundles|^/_wdt')),
37-
array(array('toolbar' => true), array('intercept_redirects' => false, 'toolbar' => true, 'position' => 'bottom', 'excluded_ajax_paths' => '^/bundles|^/_wdt')),
38-
array(array('position' => 'top'), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'top', 'excluded_ajax_paths' => '^/bundles|^/_wdt')),
34+
array(array(), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
35+
array(array('intercept_redirects' => true), array('intercept_redirects' => true, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
36+
array(array('intercept_redirects' => false), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
37+
array(array('toolbar' => true), array('intercept_redirects' => false, 'toolbar' => true, 'position' => 'bottom', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
38+
array(array('position' => 'top'), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'top', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
3939
array(array('excluded_ajax_paths' => 'test'), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => 'test')),
4040
);
4141
}

0 commit comments

Comments
 (0)