Skip to content

Commit

Permalink
Add option not to use a blob: URL for the worker source
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire committed Aug 19, 2019
1 parent 9f1e782 commit eb288fb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,11 @@ exports.defaultOptions = {
* @param {object} instance - TesseractWorker instance
* @param {object} options
* @param {string} options.workerPath - worker script path
* @param {boolean} options.preventBlobURL - do not use a blob: URL for the worker script
*/
exports.spawnWorker = (instance, { workerPath }) => {
exports.spawnWorker = (instance, { workerPath, preventBlobURL }) => {
let worker;
if (Blob && URL) {
if (Blob && URL && !preventBlobURL) {
const blob = new Blob([`importScripts("${workerPath}");`], {
type: 'application/javascript',
});
Expand Down
1 change: 1 addition & 0 deletions src/common/TesseractWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class TesseractWorker {
* @param {string} [options.cachePath=.] - @see {@link https://github.com/jeromewu/tesseract.js-utils/blob/master/src/loadLang.js}
* @param {string} [options.cacheMethod=write] - @see {@link https://github.com/jeromewu/tesseract.js-utils/blob/master/src/loadLang.js}
* @param {string} [options.dataPath=.] - @see {@link https://github.com/jeromewu/tesseract.js-utils/blob/master/src/loadLang.js}
* @param {boolean} [options.preventBlobURL=false] - do not use a blob: URL for the worker script
*
*/
constructor(options = {}) {
Expand Down
1 change: 1 addition & 0 deletions src/common/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
* of 20 MB.
*/
langPath: 'https://tessdata.projectnaptha.com/4.0.0',
preventBlobURL: false,
},
/*
* default params for recognize()
Expand Down

0 comments on commit eb288fb

Please sign in to comment.