From 010d38a8c0f6fad7f0b5e6955e5371a8121be87c Mon Sep 17 00:00:00 2001 From: TCASAS Date: Mon, 10 Apr 2017 13:41:50 +0200 Subject: [PATCH] Fix worker resolution on using minified version - When the minified version is used the resolver of the worker can not find it properly and throws 404 error. - The problem was that: - It was getting the current name of the file. - It was replacing **.js** by **.worker.js** - When it was loading the unminified version it was working fine because: - *pdf.js - .js + .worker.js* = **pdf.worker.js** - When it was loading the minified version it didtn't work because: - *pdf.min.js - .js + .worker.js* = **pdf.min.worker.js** - **pdf.min.worker.js** doesn't exist the real file name is **pdf.worker.min.js** --- src/display/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/display/api.js b/src/display/api.js index 984b27b72..82af80cc6 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -1097,7 +1097,7 @@ var PDFWorker = (function PDFWorkerClosure() { if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('PRODUCTION && !(MOZCENTRAL || FIREFOX)') && pdfjsFilePath) { - return pdfjsFilePath.replace(/\.js$/i, '.worker.js'); + return pdfjsFilePath.replace(/(\.(?:min\.)?js)$/i, '.worker$1'); } error('No PDFJS.workerSrc specified'); }