Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0e72c2e

Browse filesBrowse files
committed
applied suggested fixes:
added error handling on promise catch, moved fetch block out of XHR block, fixed method detect, matched url against excluded urls
1 parent af9225d commit 0e72c2e
Copy full SHA for 0e72c2e

File tree

Expand file treeCollapse file tree

1 file changed

+21
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+21
-7
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig
+21-7Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,18 +235,26 @@
235235
}
236236
237237
{% if excluded_ajax_paths is defined %}
238-
if (window.XMLHttpRequest && XMLHttpRequest.prototype.addEventListener) {
239-
if (window.fetch) {
240-
var oldFetch = window.fetch;
241-
window.fetch = function () {
238+
239+
if (window.fetch) {
240+
var oldFetch = window.fetch;
241+
window.fetch = function () {
242+
if (!arguments[0].match(new RegExp({{ excluded_ajax_paths|json_encode|raw }}))) {
242243
var promise = oldFetch.apply(null, arguments);
244+
245+
var method = 'GET';
246+
if (arguments[1] && arguments[1].method !== undefined) {
247+
method = arguments[1].method;
248+
}
249+
243250
var stackElement = {
244251
loading: true,
245252
error: false,
246253
url: arguments[0],
247-
method: arguments[1].method,
254+
method: method,
248255
start: new Date()
249256
};
257+
250258
requestStack.push(stackElement);
251259
promise.then(function (r) {
252260
stackElement.duration = new Date() - stackElement.start;
@@ -256,11 +264,17 @@
256264
stackElement.profile = r.headers.get('x-debug-token');
257265
stackElement.profilerUrl = r.headers.get('x-debug-token-link');
258266
Sfjs.renderAjaxRequests();
267+
}).catch(function(err) {
268+
stackElement.loading = false;
269+
stackElement.error = true;
259270
});
260271
Sfjs.renderAjaxRequests();
272+
261273
return promise;
262-
};
263-
}
274+
}
275+
};
276+
}
277+
if (window.XMLHttpRequest && XMLHttpRequest.prototype.addEventListener) {
264278
var proxied = XMLHttpRequest.prototype.open;
265279
266280
XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.