From 03cb546f29befdc959e551d742480550e24ad01a Mon Sep 17 00:00:00 2001 From: notmasteryet Date: Thu, 2 Feb 2012 21:06:13 -0600 Subject: [PATCH 1/2] FTP protocol support (#1165) --- src/core.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core.js b/src/core.js index cb601398e..a34954ab1 100644 --- a/src/core.js +++ b/src/core.js @@ -33,7 +33,8 @@ function getPdf(arg, callback) { var xhr = new XMLHttpRequest(); xhr.open('GET', params.url); xhr.mozResponseType = xhr.responseType = 'arraybuffer'; - xhr.expected = (params.url.indexOf('file:') === 0) ? 0 : 200; + xhr.expected = (params.url.indexOf('http:') === 0 || + params.url.indexOf('https:') === 0) ? 200 : 0; if ('progress' in params) xhr.onprogress = params.progress || undefined; From cba531e3cd7b3f4d37864c918e667c0ae1f90f07 Mon Sep 17 00:00:00 2001 From: notmasteryet Date: Thu, 2 Feb 2012 23:31:12 -0600 Subject: [PATCH 2/2] Fixing test execution / relative URL protocol detection --- src/core.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core.js b/src/core.js index a34954ab1..ae0f97231 100644 --- a/src/core.js +++ b/src/core.js @@ -33,8 +33,9 @@ function getPdf(arg, callback) { var xhr = new XMLHttpRequest(); xhr.open('GET', params.url); xhr.mozResponseType = xhr.responseType = 'arraybuffer'; - xhr.expected = (params.url.indexOf('http:') === 0 || - params.url.indexOf('https:') === 0) ? 200 : 0; + var protocol = params.url.indexOf(':') < 0 ? window.location.protocol : + params.url.substring(0, params.url.indexOf(':') + 1); + xhr.expected = (protocol === 'http:' || protocol === 'https:') ? 200 : 0; if ('progress' in params) xhr.onprogress = params.progress || undefined;