Skip to content

Commit

Permalink
Fix text replacements offscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
jbukl committed Nov 17, 2023
1 parent 9b62b8d commit 6290a4f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ext/js/background/offscreen-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export class TranslatorProxy {
...findTermsOptions,
enabledDictionaryMap: enabledDictionaryMapList,
excludeDictionaryDefinitions: excludeDictionaryDefinitionsList,
textReplacementsOptions: textReplacementsSerialized
textReplacements: textReplacementsSerialized
};
return this._offscreen.sendMessagePromise({action: 'findTermsOffscreen', params: {mode, text, findTermsOptions: modifiedFindTermsOptions}});
}
Expand Down
5 changes: 4 additions & 1 deletion ext/js/background/offscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ export class Offscreen {
if (!group) {
return group;
}
return group.map((opt) => ({...opt, pattern: new RegExp(opt.pattern)}));
return group.map((opt) => {
const [, pattern, flags] = opt.pattern.match(/\/(.*?)\/([a-z]*)?$/i); // https://stackoverflow.com/a/33642463
return {...opt, pattern: new RegExp(pattern, flags ?? '')};
});
});
return this._translator.findTerms(mode, text, findTermsOptions);
}
Expand Down

0 comments on commit 6290a4f

Please sign in to comment.