From 88130689589872cd6f19866680162abb46a39d7a Mon Sep 17 00:00:00 2001 From: kenvunz Date: Thu, 8 Sep 2016 12:49:11 +0700 Subject: [PATCH] Add exception for file protocol request Without this patch, it's not possible using `axios` for fetching local content for `cordova/phonegap` applications --- lib/adapters/xhr.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/adapters/xhr.js b/lib/adapters/xhr.js index 988419a..6dac3e7 100644 --- a/lib/adapters/xhr.js +++ b/lib/adapters/xhr.js @@ -55,7 +55,9 @@ module.exports = function xhrAdapter(config) { // The request errored out and we didn't get a response, this will be // handled by onerror instead - if (request.status === 0) { + // With one exception: request that using file: protocol, most browsers + // will return status as 0 even though it's a successful request + if (request.status === 0 && request.responseURL.indexOf('file:') !== 0) { return; }