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