Skip to content

Commit 25c0103

Browse files
committed
bug symfony#20724 [WebProfilerBundle] Fix AJAX panel with fetch requests (OnekO)
This PR was squashed before being merged into the 3.2 branch (closes symfony#20724). Discussion ---------- [WebProfilerBundle] Fix AJAX panel with fetch requests | Q | A | ------------- | --- | Branch? | 3.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#20723 | License | MIT | Doc PR | None Commits ------- 5527ee3 [WebProfilerBundle] Fix AJAX panel with fetch requests
2 parents 86e19d5 + 5527ee3 commit 25c0103

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,16 +243,29 @@
243243
var oldFetch = window.fetch;
244244
window.fetch = function () {
245245
var promise = oldFetch.apply(this, arguments);
246-
if (!arguments[0].match(new RegExp({{ excluded_ajax_paths|json_encode|raw }}))) {
246+
var url = arguments[0];
247+
var params = arguments[1];
248+
var paramType = Object.prototype.toString.call(arguments[0]);
249+
if (paramType === '[object Request]') {
250+
url = arguments[0].url;
251+
params = {
252+
method: arguments[0].method,
253+
credentials: arguments[0].credentials,
254+
headers: arguments[0].headers,
255+
mode: arguments[0].mode,
256+
redirect: arguments[0].redirect
257+
};
258+
}
259+
if (!url.match(new RegExp({{ excluded_ajax_paths|json_encode|raw }}))) {
247260
var method = 'GET';
248-
if (arguments[1] && arguments[1].method !== undefined) {
249-
method = arguments[1].method;
261+
if (params && params.method !== undefined) {
262+
method = params.method;
250263
}
251264
252265
var stackElement = {
253266
loading: true,
254267
error: false,
255-
url: arguments[0],
268+
url: url,
256269
method: method,
257270
type: 'fetch',
258271
start: new Date()

0 commit comments

Comments
 (0)