From 5c930514f595312a6996692df397738ba5f3eb7c Mon Sep 17 00:00:00 2001 From: Urs Wolfer Date: Mon, 13 May 2019 22:05:56 +0200 Subject: [PATCH] Fix initialization when calling from other Worker window global is not defined when Tesseract gets called from another worker. Also, when blob-type is not defined, it fails with an error like: 'Refused to execute script from 'blob:http://localhost:8080/160d4c2a-...-7af01' because its MIME type ('') is not executable.' --- src/browser/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/browser/index.js b/src/browser/index.js index a28cd08..9c1b397 100644 --- a/src/browser/index.js +++ b/src/browser/index.js @@ -16,9 +16,11 @@ exports.defaultOptions = defaultOptions; exports.spawnWorker = function spawnWorker(instance, workerOptions){ - if(window.Blob && window.URL){ - var blob = new Blob(['importScripts("' + workerOptions.workerPath + '");']) - var worker = new Worker(window.URL.createObjectURL(blob)); + if(Blob && URL){ + var blob = new Blob(['importScripts("' + workerOptions.workerPath + '");'], { + type: 'application/javascript' + }); + var worker = new Worker(URL.createObjectURL(blob)); }else{ var worker = new Worker(workerOptions.workerPath) }