Browse Source

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**
TCASAS 8 years ago
parent
commit
010d38a8c0
  1. 2
      src/display/api.js

2
src/display/api.js

@ -1097,7 +1097,7 @@ var PDFWorker = (function PDFWorkerClosure() {
if (typeof PDFJSDev !== 'undefined' && if (typeof PDFJSDev !== 'undefined' &&
PDFJSDev.test('PRODUCTION && !(MOZCENTRAL || FIREFOX)') && PDFJSDev.test('PRODUCTION && !(MOZCENTRAL || FIREFOX)') &&
pdfjsFilePath) { pdfjsFilePath) {
return pdfjsFilePath.replace(/\.js$/i, '.worker.js'); return pdfjsFilePath.replace(/(\.(?:min\.)?js)$/i, '.worker$1');
} }
error('No PDFJS.workerSrc specified'); error('No PDFJS.workerSrc specified');
} }

Loading…
Cancel
Save