Skip to content

Commit 81b3c78

Browse files
committedSep 2, 2021
interpolation pattern should always be a global regexp, not a string
1 parent d248eb5 commit 81b3c78

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed
 

Diff for: ‎src/engine.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class Engine extends EventEmitter {
2424
this.rules = []
2525
this.allowUndefinedFacts = options.allowUndefinedFacts || false
2626
this.pathResolver = options.pathResolver || defaultPathResolver
27-
const interpolation = options.interpolation || defaultInterpolation;
28-
this.interpolation = typeof interpolation === 'string' ? new RegExp(interpolation) : interpolation;
27+
this.interpolation = options.interpolation || defaultInterpolation;
28+
if(!(this.interpolation instanceof RegExp) || !this.interpolation.global) throw new Error('interpolation option must be a global regexp')
2929
this.operators = new Map()
3030
this.facts = new Map()
3131
this.status = READY

Diff for: ‎types/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export interface EngineOptions {
22
allowUndefinedFacts?: boolean;
33
pathResolver?: PathResolver;
4-
interpolation?: RegExp | string;
4+
interpolation?: RegExp;
55
}
66

77
export interface EngineResult {

0 commit comments

Comments
 (0)