mirror of
https://github.com/Redocly/redoc.git
synced 2025-01-31 01:54:08 +03:00
fix: do not load SearchWorker if disableSearch is true
(#1191)
Blob URLs may be disabled by CORS (ex: #764) but should not block execution when the disableSearch option is true
This commit is contained in:
parent
c05db38576
commit
af415e89e8
|
@ -4,21 +4,23 @@ import { OperationModel } from './models';
|
|||
|
||||
import Worker from './SearchWorker.worker';
|
||||
|
||||
let worker: new () => Worker;
|
||||
|
||||
if (IS_BROWSER) {
|
||||
try {
|
||||
// tslint:disable-next-line
|
||||
worker = require('workerize-loader?inline&fallback=false!./SearchWorker.worker');
|
||||
} catch (e) {
|
||||
function getWorker() {
|
||||
let worker: new () => Worker;
|
||||
if (IS_BROWSER) {
|
||||
try {
|
||||
// tslint:disable-next-line
|
||||
worker = require('workerize-loader?inline&fallback=false!./SearchWorker.worker');
|
||||
} catch (e) {
|
||||
worker = require('./SearchWorker.worker').default;
|
||||
}
|
||||
} else {
|
||||
worker = require('./SearchWorker.worker').default;
|
||||
}
|
||||
} else {
|
||||
worker = require('./SearchWorker.worker').default;
|
||||
return new worker();
|
||||
}
|
||||
|
||||
export class SearchStore<T> {
|
||||
searchWorker = new worker();
|
||||
searchWorker = getWorker();
|
||||
|
||||
indexItems(groups: Array<IMenuItem | OperationModel>) {
|
||||
const recurse = items => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user