From e594dfa8abc61cc51a4e679b2130f6ade28786ab Mon Sep 17 00:00:00 2001 From: gorhill Date: Sun, 26 Oct 2014 10:19:38 -0400 Subject: [PATCH] see https://github.com/gorhill/uMatrix/issues/15 --- js/assets.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/js/assets.js b/js/assets.js index b7d730928..26f881a93 100644 --- a/js/assets.js +++ b/js/assets.js @@ -226,11 +226,18 @@ var cachedAssetsManager = (function() { /******************************************************************************/ var getTextFileFromURL = function(url, onLoad, onError) { + // https://github.com/gorhill/uMatrix/issues/15 + var onResponseReceived = function() { + if ( typeof this.status === 'number' && this.status >= 200 && this.status < 300 ) { + return onLoad.call(this); + } + return onError.call(this); + }; // console.log('µBlock> getTextFileFromURL("%s"):', url); var xhr = new XMLHttpRequest(); xhr.responseType = 'text'; xhr.timeout = 15000; - xhr.onload = onLoad; + xhr.onload = onResponseReceived; xhr.onerror = onError; xhr.ontimeout = onError; xhr.open('get', url, true);