aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/json-schema.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/ext/bg/js/json-schema.js b/ext/bg/js/json-schema.js
index 85ced354..7b6b9c53 100644
--- a/ext/bg/js/json-schema.js
+++ b/ext/bg/js/json-schema.js
@@ -125,7 +125,7 @@ class JsonSchemaProxyHandler {
class JsonSchemaValidator {
constructor() {
- this._regexCache = new CacheMap(100, ([pattern, flags]) => new RegExp(pattern, flags));
+ this._regexCache = new CacheMap(100);
}
createProxy(target, schema) {
@@ -705,8 +705,12 @@ class JsonSchemaValidator {
}
_getRegex(pattern, flags) {
- const regex = this._regexCache.getOrCreate([pattern, flags]);
- regex.lastIndex = 0;
+ const key = `${flags}:${pattern}`;
+ let regex = this._regexCache.get(key);
+ if (typeof regex === 'undefined') {
+ regex = new RegExp(pattern, flags);
+ this._regexCache.set(key, regex);
+ }
return regex;
}
}