Skip to content

Commit

Permalink
fix(suggester): adapt empty regex in safari
Browse files Browse the repository at this point in the history
  • Loading branch information
jiawei686 committed Jan 5, 2022
1 parent a108ce9 commit a3027f7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/hooks/Suggester.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default class Suggester extends SyntaxBase {
if (isLookbehindSupported()) {
return str.replace(this.RULE.reg, this.toHtml.bind(this));
}
return replaceLookbehind(str, this.RULE.reg, this.toHtml.bind(this), true, 1);
return this.RULE.reg ? replaceLookbehind(str, this.RULE.reg, this.toHtml.bind(this), true, 1) : str;
}

toHtml(str) {
Expand All @@ -109,7 +109,7 @@ export default class Suggester extends SyntaxBase {

rule() {
if (!this.suggester || Object.keys(this.suggester).length <= 0) {
return {};
return new RegExp();
}
const keys = Object.keys(this.suggester)
.map((key) => escapeRegExp(key))
Expand Down

0 comments on commit a3027f7

Please sign in to comment.