|
235 | 235 | }
|
236 | 236 |
|
237 | 237 | {% 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 }}))) { |
| 243 | +
|
242 | 244 | var promise = oldFetch.apply(null, arguments);
|
| 245 | +
|
| 246 | + var method = 'GET'; |
| 247 | + if(arguments[1].method !== undefined){ |
| 248 | + method = arguments[1].method; |
| 249 | + } |
| 250 | +
|
243 | 251 | var stackElement = {
|
244 | 252 | loading: true,
|
245 | 253 | error: false,
|
246 | 254 | url: arguments[0],
|
247 |
| - method: arguments[1].method, |
| 255 | + method: method, |
248 | 256 | start: new Date()
|
249 | 257 | };
|
| 258 | +
|
250 | 259 | requestStack.push(stackElement);
|
251 | 260 | promise.then(function (r) {
|
252 | 261 | stackElement.duration = new Date() - stackElement.start;
|
|
256 | 265 | stackElement.profile = r.headers.get('x-debug-token');
|
257 | 266 | stackElement.profilerUrl = r.headers.get('x-debug-token-link');
|
258 | 267 | Sfjs.renderAjaxRequests();
|
| 268 | + }).catch(function(err) { |
| 269 | + stackElement.loading = false; |
| 270 | + stackElement.error = true; |
259 | 271 | });
|
260 | 272 | Sfjs.renderAjaxRequests();
|
| 273 | +
|
261 | 274 | return promise;
|
262 |
| - }; |
263 |
| - } |
| 275 | + } |
| 276 | + }; |
| 277 | + } |
| 278 | + if (window.XMLHttpRequest && XMLHttpRequest.prototype.addEventListener) { |
264 | 279 | var proxied = XMLHttpRequest.prototype.open;
|
265 | 280 |
|
266 | 281 | XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {
|
|
0 commit comments